Hi, we are setting up Apple Pay on our website which sells only digital goods. We don't collect a shipping address because we aren't shipping anything. We want to use the user's billing address in order to show them the total amount (including sales tax) before they authorize the purchase. However, it seems that the billing address isn't always provided by Apple Pay before the payment is authorized.
With Apple Pay, what is the recommended way of acquiring the user's billing address before they authorize the purchase?
--
More details about our setup:
We are using the Apple Pay JS API.
In createPaymentRequest, we specify requiredBillingContactFields: ['postalAddress'], but per the docs, the address is provided after the user authorizes the transaction. That is too late for us because we want to show the sales tax before the user authorizes the purchase.
We have attempted to work around this by getting the billing contact details in session.onpaymentmethodselected. For example:
session.onpaymentmethodselected = function (event) {
const billingContact = event.paymentMethod.billingContact;
// Sometimes `billingContact` exists, but other times it does not
}
This doc states:
Before the user authorizes the transaction, you receive redacted billing contact information in a callback event. The redacted information includes only the necessary data for completing transaction tasks, such as calculating taxes or shipping costs.
But in practice, we've observed that sometimes no billing contact information is provided. When a user switches from one card to another, we seem to never get the billing contact associated with the newly selected card.
Is there something we're missing?