recurly / recurly-js

Simple subscription billing in the browser
https://js.recurly.com/
MIT License
646 stars 139 forks source link

Apple Pay wrongly uses the user's shipping country as billing country #872

Open herschel666 opened 7 months ago

herschel666 commented 7 months ago

When opening the Apple Pay payment dialog, the Recurly SDK retrieves the user's shipping address and subsequently updates the Checkout Pricing instance assuming the shipping address's country to be the billing country. In case the shipping country has a different VAT rate than the billing country, this leads to a wrong price being displayed in the Apple Pay payment dialog.

Example:

Given, we have a product that costs €19.90 in Austria, including a VAT rate of 20%. If the buyer's set their shipping address to be in Germany, the German VAT rate of 19% will be applied in the Apple Pay payment dialog, leading to the wrong price of €19.73 being displayed.

cbarton commented 7 months ago

@herschel666 The Apple Pay with pricing assumes that the shipping address will be used in the subsequent purchase request which will more than likely apply tax at the destination, which in this case is the shipping address. It uses the underlying pricing.shippingAddress method to attach the shipping address to the pricing instance to which then calculates the tax.

If you are not using the shipping address when creating the purchase and would like to use the billing address as the destination when the invoice is created, we can add an option to the Apple Pay module to not set the shipping address on the pricing module when it is requested from the user. Would that be an appropriate suggestion that would solve for your use case?

herschel666 commented 6 months ago

Yes, that sounds good. We're selling a SaaS product so there won't be any shipping address required anyway.

cbarton commented 6 months ago

We can still add an option but in your case since you are not using the shipping address, does it work properly if you remove postalAddress from the requiredShippingContactFields?

herschel666 commented 6 months ago

No, I only have ["email"] set on the requiredShippingContactFields. Still, it doesn't work.

cbarton commented 6 months ago

I wonder if there is a bug in the library that needs to be investigated if that is the case. I'll do some digging next week.

cbarton commented 6 months ago

@herschel666 Unfortunately, I can't reproduce the behavior you are experiencing.

When I configure recurly.ApplePay with requiredShippingContactFields: ["email"], the shippingMethodSelected event does not trigger, and if it did there would not be a shipping contact returned. Adding "postalAddress" triggers it as expected and loads the tax estimate.

If possible, can you provide me with your recurly.ApplePay configuration