Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address Verification Failed #28

Open
arun057 opened this issue Oct 12, 2015 · 6 comments
Open

Address Verification Failed #28

arun057 opened this issue Oct 12, 2015 · 6 comments

Comments

@arun057
Copy link

arun057 commented Oct 12, 2015

I, [2015-10-12T00:04:27.710747 #6706]  INFO -- : [ActiveJob] [ActionMailer::DeliveryJob] [de203660-8042-43ea-8574-c8345570a908] Performed ActionMailer::DeliveryJob from Inline(mailers) in 832.66ms
D, [2015-10-12T00:04:27.716082 #6706] DEBUG -- :   SQL (2.5ms)  UPDATE "spree_orders" SET "confirmation_delivered" = 't' WHERE "spree_orders"."id" = $1  [["id", 63]]
D, [2015-10-12T00:04:27.722047 #6706] DEBUG -- :    (0.8ms)  SELECT COUNT(*) FROM "spree_payments" WHERE "spree_payments"."order_id" = $1 AND (avs_response IN ('A','C','E','F','G','I','K','L','N','O','P','R','S','U','W','Z') OR (cvv_response_code IS NOT NULL and cvv_response_code != 'M') OR state = 'failed')  [["order_id", 63]]
D, [2015-10-12T00:04:27.727314 #6706] DEBUG -- :   Spree::Address Load (2.6ms)  SELECT  "spree_addresses".* FROM "spree_addresses" WHERE "spree_addresses"."id" = $1 LIMIT 1  [["id", 96]]
D, [2015-10-12T00:04:27.734028 #6706] DEBUG -- :   SQL (1.7ms)  SELECT "spree_zones"."id" AS t0_r0, "spree_zones"."name" AS t0_r1, "spree_zones"."description" AS t0_r2, "spree_zones"."default_tax" AS t0_r3, "spree_zones"."zone_members_count" AS t0_r4, "spree_zones"."created_at" AS t0_r5, "spree_zones"."updated_at" AS t0_r6, "spree_zones"."kind" AS t0_r7, "spree_zone_members"."id" AS t1_r0, "spree_zone_members"."zoneable_id" AS t1_r1, "spree_zone_members"."zoneable_type" AS t1_r2, "spree_zone_members"."zone_id" AS t1_r3, "spree_zone_members"."created_at" AS t1_r4, "spree_zone_members"."updated_at" AS t1_r5 FROM "spree_zones" LEFT OUTER JOIN "spree_zone_members" ON "spree_zone_members"."zone_id" = "spree_zones"."id" WHERE ((spree_zone_members.zoneable_type = 'Spree::Country' AND spree_zone_members.zoneable_id = 232) OR (spree_zone_members.zoneable_type = 'Spree::State' AND spree_zone_members.zoneable_id = 3446))  ORDER BY spree_zones.zone_members_count, spree_zones.created_at
D, [2015-10-12T00:04:27.743453 #6706] DEBUG -- :   Spree::TaxRate Load (2.5ms)  SELECT DISTINCT spree_tax_rates.*, spree_zones.default_tax FROM "spree_tax_rates" INNER JOIN "spree_zones" ON "spree_zones"."id" = "spree_tax_rates"."zone_id" LEFT OUTER JOIN "spree_zone_members" ON "spree_zone_members"."zone_id" = "spree_zones"."id" AND "spree_zone_members"."zoneable_type" = $1 LEFT OUTER JOIN "spree_countries" ON "spree_countries"."id" = "spree_zone_members"."zoneable_id" LEFT OUTER JOIN "spree_zone_members" "zone_members_spree_countries_join" ON "zone_members_spree_countries_join"."zoneable_id" = "spree_countries"."id" AND "zone_members_spree_countries_join"."zoneable_type" = $2 LEFT OUTER JOIN "spree_zones" "zones_spree_countries" ON "zones_spree_countries"."id" = "zone_members_spree_countries_join"."zone_id" WHERE "spree_tax_rates"."deleted_at" IS NULL AND (zone_members_spree_countries_join.zone_id = 2 OR spree_zones.default_tax = 't')  ORDER BY spree_zones.default_tax DESC  [["zoneable_type", "Spree::Country"], ["zoneable_type", "Spree::Country"]]
D, [2015-10-12T00:04:27.746668 #6706] DEBUG -- :   Spree::Zone Load (0.5ms)  SELECT "spree_zones".* FROM "spree_zones" WHERE "spree_zones"."id" IN (2)
D, [2015-10-12T00:04:27.749566 #6706] DEBUG -- :   Spree::ZoneMember Load (0.5ms)  SELECT "spree_zone_members".* FROM "spree_zone_members" WHERE "spree_zone_members"."zone_id" IN (2)
D, [2015-10-12T00:04:27.752587 #6706] DEBUG -- :   Spree::Country Load (0.5ms)  SELECT "spree_countries".* FROM "spree_countries" WHERE "spree_countries"."id" IN (232)
D, [2015-10-12T00:04:27.756738 #6706] DEBUG -- :   Spree::Calculator Load (0.4ms)  SELECT  "spree_calculators".* FROM "spree_calculators" WHERE "spree_calculators"."deleted_at" IS NULL AND "spree_calculators"."calculable_id" = $1 AND "spree_calculators"."calculable_type" = $2 LIMIT 1  [["calculable_id", 2], ["calculable_type", "Spree::TaxRate"]]
D, [2015-10-12T00:04:27.762834 #6706] DEBUG -- :   Spree::State Load (0.4ms)  SELECT  "spree_states".* FROM "spree_states" WHERE "spree_states"."id" = $1 LIMIT 1  [["id", 3446]]
D, [2015-10-12T00:04:27.764564 #6706] DEBUG -- :   CACHE (0.0ms)  SELECT  "spree_states".* FROM "spree_states" WHERE "spree_states"."id" = $1 LIMIT 1  [["id", 3446]]
D, [2015-10-12T00:04:27.767652 #6706] DEBUG -- :   Spree::Product Load (0.3ms)  SELECT  "spree_products".* FROM "spree_products" WHERE "spree_products"."id" = $1 LIMIT 1  [["id", 35]]
D, [2015-10-12T00:04:27.770124 #6706] DEBUG -- :   Spree::Preference Load (0.3ms)  SELECT  "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = $1 LIMIT 1  [["key", "spree/app_configuration/taxcloud_shipping_tic"]]
D, [2015-10-12T00:04:27.863669 #6706] DEBUG -- :   CACHE (0.1ms)  SELECT DISTINCT spree_tax_rates.*, spree_zones.default_tax FROM "spree_tax_rates" INNER JOIN "spree_zones" ON "spree_zones"."id" = "spree_tax_rates"."zone_id" LEFT OUTER JOIN "spree_zone_members" ON "spree_zone_members"."zone_id" = "spree_zones"."id" AND "spree_zone_members"."zoneable_type" = $1 LEFT OUTER JOIN "spree_countries" ON "spree_countries"."id" = "spree_zone_members"."zoneable_id" LEFT OUTER JOIN "spree_zone_members" "zone_members_spree_countries_join" ON "zone_members_spree_countries_join"."zoneable_id" = "spree_countries"."id" AND "zone_members_spree_countries_join"."zoneable_type" = $2 LEFT OUTER JOIN "spree_zones" "zones_spree_countries" ON "zones_spree_countries"."id" = "zone_members_spree_countries_join"."zone_id" WHERE "spree_tax_rates"."deleted_at" IS NULL AND (zone_members_spree_countries_join.zone_id = 2 OR spree_zones.default_tax = 't')  ORDER BY spree_zones.default_tax DESC  [["zoneable_type", "Spree::Country"], ["zoneable_type", "Spree::Country"]]
D, [2015-10-12T00:04:27.866339 #6706] DEBUG -- :   CACHE (0.0ms)  SELECT "spree_zones".* FROM "spree_zones" WHERE "spree_zones"."id" IN (2)
D, [2015-10-12T00:04:27.868517 #6706] DEBUG -- :   CACHE (0.0ms)  SELECT "spree_zone_members".* FROM "spree_zone_members" WHERE "spree_zone_members"."zone_id" IN (2)
D, [2015-10-12T00:04:27.871017 #6706] DEBUG -- :   CACHE (0.0ms)  SELECT "spree_countries".* FROM "spree_countries" WHERE "spree_countries"."id" IN (232)
D, [2015-10-12T00:04:27.874364 #6706] DEBUG -- :   CACHE (0.0ms)  SELECT  "spree_calculators".* FROM "spree_calculators" WHERE "spree_calculators"."deleted_at" IS NULL AND "spree_calculators"."calculable_id" = $1 AND "spree_calculators"."calculable_type" = $2 LIMIT 1  [["calculable_id", 2], ["calculable_type", "Spree::TaxRate"]]
I, [2015-10-12T00:04:27.952353 #6706]  INFO -- : Redirected to https://www.clubpatina.com/checkout/address
I, [2015-10-12T00:04:27.953042 #6706]  INFO -- : Completed 302 Found in 3796ms (ActiveRecord: 135.2ms)
I, [2015-10-12T00:04:27.983141 #6706]  INFO -- : Started GET "/checkout/address" for 68.173.232.164 at 2015-10-12 00:04:27 -0400
I, [2015-10-12T00:04:27.986804 #6706]  INFO -- : Processing by Spree::CheckoutController#edit as HTML
I, [2015-10-12T00:04:27.986972 #6706]  INFO -- :   Parameters: {"state"=>"address"}
D, [2015-10-12T00:04:27.990151 #6706] DEBUG -- :   Spree::Preference Load (0.4ms)  SELECT  "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = $1 LIMIT 1  [["key", "spree/frontend_configuration/locale"]]
D, [2015-10-12T00:04:27.996432 #6706] DEBUG -- :   Spree::Store Load (0.8ms)  SELECT  "spree_stores".* FROM "spree_stores" WHERE (url like '%www.clubpatina.com%')  ORDER BY "spree_stores"."id" ASC LIMIT 1
D, [2015-10-12T00:04:28.001218 #6706] DEBUG -- :   Spree::Order Load (2.0ms)  SELECT  "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."completed_at" IS NULL AND "spree_orders"."currency" = $1 AND "spree_orders"."guest_token" = $2 AND "spree_orders"."store_id" = $3 AND "spree_orders"."user_id" IS NULL LIMIT 1 FOR UPDATE  [["currency", "USD"], ["guest_token", "xP2xoJ_ptsYLxNg_W82C5g"], ["store_id", 1]]
I, [2015-10-12T00:04:28.003669 #6706]  INFO -- : Redirected to https://www.clubpatina.com/cart
I, [2015-10-12T00:04:28.003972 #6706]  INFO -- : Filter chain halted as :load_order_with_lock rendered or redirected
I, [2015-10-12T00:04:28.004393 #6706]  INFO -- : Completed 302 Found in 17ms (ActiveRecord: 3.2ms)
I, [2015-10-12T00:04:28.032878 #6706]  INFO -- : Started GET "/cart" for 68.173.232.164 at 2015-10-12 00:04:28 -0400
I, [2015-10-12T00:04:28.036017 #6706]  INFO -- : Processing by Spree::OrdersController#edit as HTML
D, [2015-10-12T00:04:28.039181 #6706] DEBUG -- :   Spree::Preference Load (0.4ms)  SELECT  "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = $1 LIMIT 1  [["key", "spree/frontend_configuration/locale"]]
D, [2015-10-12T00:04:28.043591 #6706] DEBUG -- :   Spree::Order Load (0.9ms)  SELECT  "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."number" IS NULL LIMIT 1
D, [2015-10-12T00:04:28.047169 #6706] DEBUG -- :   Spree::Store Load (0.8ms)  SELECT  "spree_stores".* FROM "spree_stores" WHERE (url like '%www.clubpatina.com%')  ORDER BY "spree_stores"."id" ASC LIMIT 1
D, [2015-10-12T00:04:28.049688 #6706] DEBUG -- :   Spree::Order Load (0.4ms)  SELECT  "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."completed_at" IS NULL AND "spree_orders"."currency" = $1 AND "spree_orders"."guest_token" = $2 AND "spree_orders"."store_id" = $3 AND "spree_orders"."user_id" IS NULL LIMIT 1  [["currency", "USD"], ["guest_token", "xP2xoJ_ptsYLxNg_W82C5g"], ["store_id", 1]]
D, [2015-10-12T00:04:28.060850 #6706] DEBUG -- :   CACHE (0.0ms)  SELECT  "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."completed_at" IS NULL AND "spree_orders"."currency" = $1 AND "spree_orders"."guest_token" = $2 AND "spree_orders"."store_id" = $3 AND "spree_orders"."user_id" IS NULL LIMIT 1  [["currency", "USD"], ["guest_token", "xP2xoJ_ptsYLxNg_W82C5g"], ["store_id", 1]]
D, [2015-10-12T00:04:28.064420 #6706] DEBUG -- :   Spree::Order Load (1.0ms)  SELECT  "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."completed_at" IS NULL AND "spree_orders"."guest_token" = $1 LIMIT 1  [["guest_token", "xP2xoJ_ptsYLxNg_W82C5g"]]
I, [2015-10-12T00:04:28.077305 #6706]  INFO -- :   Rendered spree/orders/edit.html.erb within spree/layouts/spree_application (5.3ms)
I, [2015-10-12T00:04:28.082604 #6706]  INFO -- :   Rendered spree/shared/_head.html.erb (4.2ms)
I, [2015-10-12T00:04:28.086492 #6706]  INFO -- :   Rendered spree/shared/_nav_bar.html.haml (2.2ms)
I, [2015-10-12T00:04:28.086763 #6706]  INFO -- :   Rendered spree/shared/_header.html.haml (3.6ms)
I, [2015-10-12T00:04:28.092135 #6706]  INFO -- :   Rendered spree/shared/_footer.html.haml (4.6ms)
D, [2015-10-12T00:04:28.096043 #6706] DEBUG -- :   Spree::Tracker Load (1.1ms)  SELECT  "spree_trackers".* FROM "spree_trackers" WHERE "spree_trackers"."active" = 't'  ORDER BY "spree_trackers"."id" ASC LIMIT 1
I, [2015-10-12T00:04:28.097366 #6706]  INFO -- :   Rendered spree/shared/_google_analytics.html.erb (4.7ms)
I, [2015-10-12T00:04:28.098131 #6706]  INFO -- : Completed 200 OK in 62ms (Views: 29.0ms | ActiveRecord: 4.5ms)
I, [2015-10-12T00:04:28.383041 #6706]  INFO -- : Started GET "/cart_link" for 68.173.232.164 at 2015-10-12 00:04:28 -0400
I, [2015-10-12T00:04:28.386258 #6706]  INFO -- : Processing by Spree::StoreController#cart_link as */*
D, [2015-10-12T00:04:28.389333 #6706] DEBUG -- :   Spree::Preference Load (0.3ms)  SELECT  "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = $1 LIMIT 1  [["key", "spree/frontend_configuration/locale"]]
D, [2015-10-12T00:04:28.395835 #6706] DEBUG -- :   Spree::Store Load (0.9ms)  SELECT  "spree_stores".* FROM "spree_stores" WHERE (url like '%www.clubpatina.com%')  ORDER BY "spree_stores"."id" ASC LIMIT 1
D, [2015-10-12T00:04:28.398927 #6706] DEBUG -- :   Spree::Order Load (0.5ms)  SELECT  "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."completed_at" IS NULL AND "spree_orders"."currency" = $1 AND "spree_orders"."guest_token" = $2 AND "spree_orders"."store_id" = $3 AND "spree_orders"."user_id" IS NULL LIMIT 1  [["currency", "USD"], ["guest_token", "xP2xoJ_ptsYLxNg_W82C5g"], ["store_id", 1]]
I, [2015-10-12T00:04:28.401515 #6706]  INFO -- :   Rendered spree/shared/_link_to_cart.html.erb (9.4ms)
I, [2015-10-12T00:04:28.402713 #6706]  INFO -- : Completed 200 OK in 16ms (Views: 9.2ms | ActiveRecord: 1.8ms)

This happens after the order is placed and email is delivered successfully. Spree admin shows the order as ready to ship

@brchristian
Copy link
Contributor

@arun057 At the moment the spree_tax_cloud extension doesn't do any address validation (it's on the roadmap, and PRs are welcome!). However, issues in the address—for instance, a ZIP code that doesn't match the state—may still cause the tax_cloud API to return an error, in which case the error propagates up to Spree.

At the moment this gem doesn't contain the functionality to do an address validation with TaxCloud and return the user to the Spree address checkout step if it doesn't pass.

I would certainly love for it to do that, however, and any PRs to that effect would be very welcome!

Otherwise, it's possible that I may get to it later this year.

@rloomba
Copy link

rloomba commented Feb 19, 2016

I'm seeing this error as well. I've added in some logging to see what the actual error is from TaxCloud:

Spree::CheckoutController.class_eval do

  rescue_from SpreeTaxCloud::Error do |exception|
    flash[:error] = exception.message
    Rails.logger.info("SpreeTaxCloud Error: #{exception.inspect}")
    redirect_to checkout_state_path(:address)
  end

  rescue_from TaxCloud::Errors::ApiError do |exception|
    flash[:error] = Spree.t("address_verification_failed")
    Rails.logger.info("TaxCloud API Error: #{exception.inspect}")
    redirect_to checkout_state_path(:address)
  end

end

Here is a snippet of the log:

00:00 app web.1 - - TaxCloud API Error: #<TaxCloud::Errors::ApiError:
» 19 Feb 2016 11:03:20.052 2016-02-19 19:03:20.016989+00:00 app web.1 - - Problem:
» 19 Feb 2016 11:03:20.052 2016-02-19 19:03:20.016990+00:00 app web.1 - - A matching lookup could not be found for this authorization (CartID : **************)
» 19 Feb 2016 11:03:20.052 2016-02-19 19:03:20.016991+00:00 app web.1 - - Summary:
» 19 Feb 2016 11:03:20.052 2016-02-19 19:03:20.016992+00:00 app web.1 - - The TaxCloud server returned an error in the response: `{:authorized_with_capture_response=>{:authorized_with_capture_result=>{:response_type=>"Error", :messages=>{:response_message=>{:response_type=>"Error", :message=>"A matching lookup could not be found for this authorization (CartID : *************)"}}}, :@xmlns=>"http://taxcloud.net"}}`
» 19 Feb 2016 11:03:20.052 2016-02-19 19:03:20.016993+00:00 app web.1 - - Resolution:
» 19 Feb 2016 11:03:20.052 2016-02-19 19:03:20.016994+00:00 app web.1 - - Check the request parameters.>
» 19 Feb 2016 11:03:20.131 2016-02-19 19:03:20.017957+00:00 app web.1 - - Redirected to https://mysite.com/checkout/address
» 19 Feb 2016 11:03:20.302 2016-02-19 19:03:20.043407+00:00 app web.1 - - source=rack-timeout id=3d3d3cd4-3e4f-4a38-943a-9f42dbed35e1 wait=4ms timeout=15000ms service=6608ms state=completed High Response Time
» 19 Feb 2016 11:03:20.309 2016-02-19 19:03:20.034702+00:00 app web.1 - - Completed 302 Found in 6594ms (ActiveRecord: 820.7ms)
» 19 Feb 2016 11:03:25.728 2016-02-19 19:03:25.469831+00:00 app web.1 - - source=rack-timeout id=9db30969-3815-440f-8e94-35b9d0ea0f8a wait=0ms timeout=15000ms state=ready
» 19 Feb 2016 11:03:25.745 2016-02-19 19:03:25.470864+00:00 app web.1 - - Started GET "/checkout/address" for 162.93.80.2 at 2016-02-19 19:03:25 +0000

The address looks fine, no mismatched zip code or state. The Spree Order actually goes through (so I'm assuming this proves there's nothing wrong with the billing or shipping information?).

Wondering if anyone has any more information on this type of error from TaxCloud?

@brchristian
Copy link
Contributor

@rloomba Without being able to inspect it more deeply at the moment, I know that TaxCloud expects first to "authorize" an order and then to "capture" it. If it changes from the one to the other, there may be an error. So I would look into the logs and see what's going on at the "authorization" level.

Spree itself does not (to my knowledge) do any kind of address verification, so I'm not surprised that the order is getting through – from Spree's perspective, there is some address filled out, so it's happy.

The other possibility is that this is a complex address where the zip code may require the additional 4 digits, or may be different from the main zip code for that town -- something like that.

If that's the case, I think you'd be able to reproduce the error for specific addresses reliably, but not for others. Is that the case with your store, or does it happen more erratically or more broadly? It might be worth bringing up with TaxCloud as well.

As I mentioned earlier in this thread, address verification is one of the missing features in the Spree::TaxCloud extension, and the Spree team and I would be very happy to receive a PR implementing that!

@rloomba
Copy link

rloomba commented Feb 22, 2016

I know that TaxCloud expects first to "authorize" an order and then to "capture" it. If it changes from the one to the other, there may be an error.

thanks @brchristian for this insight, will dig into the logs more and report back.

The other possibility is that this is a complex address where the zip code may require the additional 4 digits, or may be different from the main zip code for that town -- something like that.

Unfortunately, this is not the case for any of the errors I'm seeing.

If that's the case, I think you'd be able to reproduce the error for specific addresses reliably, but not for others. Is that the case with your store, or does it happen more erratically or more broadly? It might be worth bringing up with TaxCloud as well.

It's happening very erratically on my current store. I'm not noticing a pattern.

I would love to implement address verification, I'll see if I can squeeze it into some spare cycles.

@rloomba
Copy link

rloomba commented Feb 24, 2016

@brchristian One thing I've been noticing is that we're seeing this error occur for products that aren't supposed to be taxed.

In my backend setup I have created a tax category, Taxable, and a tax rate Sales Tax that uses the Tax Cloud Calculator and is associated to the tax category taxable.

For products that are not supposed to be taxed, the tax category is set to none, but I'm still seeing a box with a TaxCloud TIC:
image

and it appears to be making an API call to TaxCloud even though it's not a taxble product. Is this the intended behavior?

I'm on Spree 2.4, and running Rails 4.1.11.

@brchristian
Copy link
Contributor

@rloomba It would be possible to make a PR that disabled the TaxCloud TIC box on the backend, but I think it's safer to leave it as is, as the Product would need to know that the Tax Category was connected to TaxCloud (which could change later, etc.). My feeling is that the backend should probably just stay as is. That said, I'm open to discussing PRs on that if you have ideas for improvements.

If I recall correctly, TaxCloud expects to process all Spree orders that ship within the United States, including ones with tax-free items. My guess (without looking into the code) is that an order containing a mix of Tax Categories will confuse TaxCloud. This could probably be made to perform more stably, but on the other hand, the plugin is designed to be used for all products.

I believe the preferred method for making items tax-free is to set the TaxCloud TIC to the appropriate code. What are your tax-free Products, for instance? It should be possible to find the appropriate TIC for those, and I think that (using the TaxCloud Tax Category but a tax-free TIC) will give you the behavior you're looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants