Sha256: 3519f8c0c0afb01a19fbea3c8f30c896a0068a6f02b071e48535bfd8f2259694

Contents?: true

Size: 584 Bytes

Versions: 4

Compression:

Stored size: 584 Bytes

Contents

Spree::CheckoutController.class_eval do
  def validate_address
    mytax = TaxSvc.new
    address = permitted_address_validation_attrs

    address['Country'] = Spree::Country.find_by(id: address['Country']).try(:iso)
    address['Region'] = Spree::State.find_by(id: address['Region']).try(:abbr)

    response = mytax.validate_address(address)

    respond_to do |format|
      format.json { render json: response }
    end
  end


  private

  def permitted_address_validation_attrs
    params['address'].permit(:Line1, :Line2, :City, :PostalCode, :Country, :Region).to_h
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solidus_avatax_certified-3.0.0 app/controllers/spree/checkout_controller_decorator.rb
solidus_avatax_certified-2.0.0 app/controllers/spree/checkout_controller_decorator.rb
solidus_avatax_certified-1.1.0 app/controllers/spree/checkout_controller_decorator.rb
solidus_avatax_certified-1.0.0 app/controllers/spree/checkout_controller_decorator.rb