0

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

Lucas Ocon
  • 172
  • 2
  • 7

1 Answers1

0

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

Lucas Ocon
  • 172
  • 2
  • 7