Skip to content

Instantly share code, notes, and snippets.

@rterbush
Last active December 17, 2015 16:48
Show Gist options
  • Save rterbush/5641100 to your computer and use it in GitHub Desktop.
Save rterbush/5641100 to your computer and use it in GitHub Desktop.
def destination_address(address)
addrobj = TaxCloud::Address.new({
:address1 => address.address1,
:address2 => address.address2,
:city => address.city,
:state => address.state.abbr,
:zip5 => address.zipcode[0..4]
})
begin
verified_address = addrobj.verify
binding.pry
rescue_from TaxCloud::Errors::ApiError do |exception|
redirect_to('/checkout/delivery', flash: "Address Verification Failed")
end
end
{
'Address1' => verified_address.address1,
'Address2' => verified_address.address2,
'City' => verified_address.city,
'State' => verified_address.state,
'Zip5' => verified_address.zip5,
'Zip4' => verified_address.zip4
}
end
@joshnuss
Copy link

# http://api.rubyonrails.org/classes/ActiveSupport/Rescuable/ClassMethods.html
rescue_from TaxCloud::Errors::ApiError do |exception|
   redirect_to(some_path, notice: exception.message)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment