Apple Pay JS token amount mismatch (missing Address Line 1)

Hi,

We have a public website using Apple Pay with the JS Library. We use Adyen as payment gateway and Avalara to calculate taxes. We've recently discovered a lot of errors in regards of ApplePay token amount-mismatch errorType error. This mean the amount authorized by ApplePay does not match the amount sent to Adyen for authorization. Here's the root cause:

  1. Applepay only reports full address including address line 1 after  user authorizes the transaction with ApplePay using the session.onshippingcontactselected event. At this point we only have the following - City, Region, Country, Zip

  2. So, the total order value is based on what Avalara reports the tax is using these fields. For an example order using this zip code 94534, the tax is calculated as $1.84 at this point.

  3. After we receive the authorization from Applepay, we also receive the full address. This address is then sent to the backend to recalculate the cart (including tax). This is just before calling Adyen API

  4. For this specific cart, since now the Address has AddressLine1, the zip code (94534) along with address line 1 results in a different tax from Avalara ($2.09)

So, the cart total is more than the amount that was authorized in Applepay token.

This could easily be solved if we can make Apple Pay to return the AddressLine1 from the initial callback to session.onshippingcontactselected, this would solve our problems. Is there a way to force the call to session.onshippingcontactselected to return the AddressLine1 field as part of the response?
Is there any work around for this?

Thanks and Regards
Hi,
did you find a solution to this problem? We have the exact same setup... Adyen with Avalara.
I think most other webshops do not charge the Taxes on Top so for them it doesn't matter if the final Tax Amount is lower or higher.... :-/

Hey despinoSpecialized, We also have the similar setup, did you find any solution to this?

Hi All, found a solution to this. Noticed that SFCC is calling calculate hook before and after some of the ApplePayHooks, and Implementation of Avalara Tax system requires condition in this hook as follows:

if (calculateAvalaraTax) {
    // Tax Calcuation Logic
}

If Avalara Tax is enabled, the same tax calculation logic should be executed on calculate hook that is being called from SFCC ApplePayHooks. To achieve this, updated the condition as follows:

if (calculateAvalaraTax || (request.httpPath && request.httpPath.indexOf('__SYSTEM__ApplePay') > -1)) {
    // Tax Calcuation Logic
}

This solved the issue, hope this helps, thanks!

Apple Pay JS token amount mismatch (missing Address Line 1)
 
 
Q