0

Trying to implement ApplePay for Web using ApplePay.js. If the user enters an invalid shipping address, I'd like to highlight an error on the paysheet so that the user has a chance to correct the issue. I see there is an ApplePayError class here: https://developer.apple.com/documentation/applepayjs/applepayerror, however I have no idea how to utilize this class. I've tried this with no luck:

var err = new ApplePayError("shippingContactInvalid", "postalAddress", "Address is invalid");

Is this even right? It doesn't display any error on the paysheet so I think it's wrong but I don't know how to do this and I can't seem to find any information about it's usage. Can someone point me in the right direction here?

Brandon Spilove
  • 1,449
  • 1
  • 9
  • 14

1 Answers1

1

Ensure version 3 of Apple Pay js api is being used to create the ApplePaySession.

Then pass a result object with status and errors into a 'completion' method:

var err = new ApplePayError("shippingContactInvalid", "postalAddress", "Address is invalid");
    session.completePayment({
        status: ApplePaySession.STATUS_FAILURE,
        errors: [ err ]
    });
thomas
  • 11
  • 1