javascriptbraintreeapplepayjs

Apple Pay - get full shipping address (containing 'addressLines')


I'm doing an Apple Pay WEB integration (using JS) and Braintree as a payment provider.

I need to calculate some taxes (US sales tax) for the order. Current flow: The user clicks Pay with Apple Pay button, the Apple Pay payment sheet is displayed (we require shipping address containing the postal address,zipcode,name and email).

After that the payment sheet is displayed -> I call the session.onshippingcontactselected function, but at this point I can only get the locality,administrativeArea,postalCode,country and countryCode values from the shippingContact, so I'm not getting the addressLines containing the street name and its number. I need these values as well to accurately calculate my tax.

I know that Apple says in docs that they only provide the full address after the user authorizes the payment, meaning after the payment was done (this is too late for me, cause I need to know the tax amount before the order is being placed/before the user authorizes/pays the order).

Is there a workaround through this?


Solution

  • Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.

    As this information is delivered by Apple directly, there isn't a means by which you could circumvent the redacted shippingContact information provided in the pre-authorized session using Braintree's integration. If you need the full address to calculate tax you'd need to collect that from your customer earlier in the payment process or use a different means to calculate tax using the information provided in the shippingContact object. I'd recommend sending our support team an email to discuss this further.