episerver / CommercePaymentGateways

Open-sourced payment gateways for Episerver Commerce
Apache License 2.0
7 stars 2 forks source link

PayPal gateway is overwriting order address Id #2

Open marisks opened 7 years ago

marisks commented 7 years ago

PayPal gateway overwrites order address Id which causes order to become invalid. Payments/shipments lose the reference to their addresses. This line of code does it: https://github.com/episerver/CommercePaymentGateways/blob/master/EPiServer.Business.Commerce.Payment.PayPal/Helpers/AddressHandling.cs#L59

vietanh-optimizely commented 6 years ago

Hi, Order address is saved as customer address (method TrySaveCustomerAddress) Customer address Name is set by order address Id. In case duplicate name, then address name is added with "addressCount" (see table cls_Address and below line of code) https://github.com/episerver/CommercePaymentGateways/blob/master/EPiServer.Business.Commerce.Payment.PayPal/Helpers/AddressHandling.cs#L143

I created 2 orders, checkout with PayPal, and select 2 different addresses but same name on PayPal. The orders still refer to correct address, not losing reference. Is this the case you mentioned? Or you can you please give more details?

/Viet Anh

marisks commented 6 years ago

I have a latest Episerver Commerce installed and this PayPal gateway. When I create an order (through customer UI and not from the Commerce Manager), then after checkout there is no billing address or shipping address in the Commerce Manager.

The reason is that orderAddress.Id is automatically generated by Episerver when using new APIs. But this code: https://github.com/episerver/CommercePaymentGateways/blob/master/EPiServer.Business.Commerce.Payment.PayPal/Helpers/AddressHandling.cs#L59 overwrites it. It should be removed. After this fix everything works fine.