0
votes

I'm using Apple Pay integration with Stripe and I need to get the shippingAddress from Apple Pay before shown the order information because I need to calculate taxes and shipment cost based on the address.

Currently, I can get the shipmentAddress but after show the window with the information.

I'm sending this payload:

    var paymentRequest = {
      requiredShippingContactFields: ['postalAddress','email', 'phone'],
      countryCode: 'US',
      currencyCode: 'USD',
      lineItems: this.buildLineItems(lineItems),
      total: this.buildTotal(lineItems)
    };

There's a way to get the shipment information before show the window or update the window based on the information that I get?

Source:

Thanks

1
Are you using Checkout or Elements (with the Payment Request Button)?thmsdnnr
@thmsdnnr I'm following this guide stripe.com/docs/apple-pay/web/v2Lucas Ocon

1 Answers

0
votes

In order to get the shipment information you need to listen for onshippingcontactselected

session.onshippingcontactselected = (event) => {
  // You can do work asynchronously here; just call
  // session.completeShippingMethodSelection when you're done.
}

Documentation

https://stripe.com/docs/stripe-js/reference#payment-request-on

https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778009-onshippingcontactselected?language=javascript