Apple Pay onmerchantvalidation doesn't complete

326 Views Asked by At

I'm implementing Apple Pay using the Payment Request API. I'm having a problem similar to this SO question except the opposite: the Payment Sheet doesn't get cancelled, it just times out after 30 seconds. I've tried the suggestions in that question (certificate, verified domain, exact syntax in Json) with no success.

Here is the problem:

  • I call request.show()
  • request.onmerchantvalidation(event) fires
  • I call my back end which gets a session
  • I pass this (an an object, not a string) to event.complete()
  • 30 seconds passes
  • I get an error (in the try / catch around request.show()) of errorAbortError: The operation was aborted. which is the same error I'd get if I had canceled the Payment Sheet as the user

I've gone over the example code on the ApplePayDemo site half a dozen times and I don't see anything I'm missing. Anyone have any ideas?

1

There are 1 best solutions below

0
On BEST ANSWER

So it turns out that there were two events I need to subscribe to then then just say there was nothing that needed to be updated:

  request.onpaymentmethodchange = event => {
    event.updateWith({});
  };

      // @ts-ignore
  request.onshippingaddresschange = event => {
    event.updateWith({});
  };