solidusio / solidus_paypal_braintree

⛔️ [Archived] Use solidus_braintree instead!
https://github.com/solidusio/solidus_braintree
BSD 3-Clause "New" or "Revised" License
37 stars 78 forks source link

Paypal transactions flatten addresses #301

Open hrdchz opened 2 years ago

hrdchz commented 2 years ago

Is there any reason not to adopt the approach outlined in #163 (decorator to set TransactionImport#address to nil)?

Potentially a more friendly solution would be to only correct the Billing Address if it differs from the one returned from Paypal. It is a common practice to use a different shipping address to send a gift, for example.

The same block also includes a bit about unsetting @tax_zone in the order:

        if address
          order.shipping_address = order.billing_address = address
          # work around a bug in most solidus versions
          # about tax zone cachine between address changes
          order.instance_variable_set("@tax_zone", nil)
        end

Occasionally we have an order come through from Paypal that is missing the shipping tax adjustment even though they paid the correct amount on Paypal. I'll have to look in the core commits to see if anything resolved that "zone caching" issue this tries to circumvent, but I'd be happy to submit a PR that:

  1. no longer overwrites the shipping address
  2. does not unset @tax_zone (if that's an appropriate thing to do, I'm unfamiliar with the history / context)
hrdchz commented 2 years ago

ok yea there's more to unpack here than that.

  1. The shipping address is sent up to paypal
  2. Choosing "guest checkout" populates the billing address with that shipping address in the Paypal dialog
  3. The shipping address is not editable on Paypal
  4. A Transaction needs the address to validate
  5. import! sets the bill and ship address of the order to be that single address

Not sure why that import of the address needs to happen when it can't be edited on Paypal

hrdchz commented 2 years ago

Ok, I think there might be some reason to make this a configurable setting now I have dug in a bit. If I have time in the future, I will submit a PR. It seems like this would be useful in some case where Paypal has not received an address from Solidus. In our storefront, we are using basically the default paypal buttons provided in the extension, which are very similar to the demo code suggested by Braintree.

For anyone experiencing this issue, #163 does prevent the transaction from Paypal from setting the Bill Address of the order to the Ship Address.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.