spree_gateway icon indicating copy to clipboard operation
spree_gateway copied to clipboard

Authorize.net CIM not getting Shipping Address

Open onedanshow opened this issue 10 years ago • 11 comments

I've got a pretty run-of-the-mill setup for Spree on royalsportltd.com. However, it appears spree_gateway is not sending the shipping address to Authorize.net CIM. It does work when sending just using plain Authorize.net. I thought I could fix the issue by uncommenting and changing this line:

https://github.com/onedanshow/spree_gateway/commit/b5953116ac11b08da3bfdf8eac5dbb8c7a76d04b#diff-d41d8cd98f00b204e9800998ecf8427e

Anyone else having this problem?

We've got a billing-shipping mismatch fraud filter that is catching the problem.

Original post: https://groups.google.com/forum/#!topic/spree-user/5RKsLjCY2ps

onedanshow avatar Aug 24 '14 14:08 onedanshow

It looks like the formatting for how to add a shipping address for Authorize.net has changed since the class in spree_gateway tried to implement it. There is nothing for the following in spree_gateway's class for Authorize.net CIM:

https://github.com/Shopify/active_merchant/blob/127be6da129c198319cbbc3dca720cbfc07f6980/lib/active_merchant/billing/gateways/authorize_net.rb#L313

Spree Gateway's non-CIM class just uses ActiveMerchant's default class, hence why it includes the shipping address. I'll look into create a pull request for adding the shipping address on CIM in spree_gateway.

onedanshow avatar Aug 24 '14 22:08 onedanshow

This documentation from Authorize.net still says use the "shipToList" key, though: http://www.authorize.net/support/CIM_XML_guide.pdf

(Documenting for future reference)

onedanshow avatar Aug 24 '14 22:08 onedanshow

Here is what I learned:

CIM does get the shipping and billing address saved with the profile after a Spree::Payment is created and create_profile is called: https://github.com/spree/spree_gateway/blob/master/app/models/spree/gateway/authorize_net_cim.rb#L52

If this line is uncommented and changed to what I have in my repo: https://github.com/spree/spree_gateway/blob/master/app/models/spree/gateway/authorize_net_cim.rb#L117

However, the create_transaction method is what is called to perform a capture, authorization, etc. and it was goes through the shipping/billing mismatch filter: https://github.com/spree/spree_gateway/blob/master/app/models/spree/gateway/authorize_net_cim.rb#L76

That method needs to be extended to include the "customerShippingAddressId" as the CIM documentation has it. However, the ID of the shipping address saved to CIM is not saved on the Spree side, just the profile ID and payment profile ID. Would probably need to save a "gateway_shipping_address_id" on some model like Spree::Creditcard has.

onedanshow avatar Aug 25 '14 03:08 onedanshow

I've made some tweaks so that the gateway options are used, but I'm still not seeing shipping address get set even with ship_to_list option... I'm not sure the best solution to this issue it seems like we need to call the create shipping address method separately.

JDutil avatar Sep 18 '14 20:09 JDutil

Yeah, I believe CIM wants you to pass the ID that it has for shipping address to use when charging the card. Spree doesn’t store gateway IDs for addresses through, just the payment profile.

On Sep 18, 2014, at 3:27 PM, Jeff Dutil [email protected] wrote:

I've made some tweaks so that the gateway options are used, but I'm still not seeing shipping address get set even with ship_to_list option... I'm not sure the best solution to this issue it seems like we need to call the create shipping address method separately.

— Reply to this email directly or view it on GitHub.

onedanshow avatar Sep 18 '14 20:09 onedanshow

Is Authorize.net CIM still broken?

jimjimovich avatar Mar 10 '15 16:03 jimjimovich

Is it broken? No. Is this still an issue? Yes.

JDutil avatar Mar 10 '15 16:03 JDutil

We're still using Auth.net CIM for our existing stores, but the new store we're working on will be using Stripe. Auth.net feels likes the Windows XP of payment gateways.

onedanshow avatar Mar 10 '15 16:03 onedanshow

That would be because it is...

JDutil avatar Mar 10 '15 17:03 JDutil

Are you guys testing this on the master branch of spree_gateway? I just wanted to know to parse some information about some other bugs I'm seeing

jasonfb avatar Mar 12 '15 14:03 jasonfb

I believe I tested with 2.4 at the time, and believe this would still remain an issue on master

JDutil avatar Mar 12 '15 16:03 JDutil