spree_gateway
spree_gateway copied to clipboard
Authorize.net CIM not getting Shipping Address
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
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.
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)
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.
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.
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.
Is Authorize.net CIM still broken?
Is it broken? No. Is this still an issue? Yes.
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.
That would be because it is...
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
I believe I tested with 2.4 at the time, and believe this would still remain an issue on master