Address validation on full address (not redacted)

We're implementing Apple Pay as an Adyen Web Component https://docs.adyen.com/payment-methods/apple-pay/web-component on the basket page of an e-commerce website selling physical goods for delivery.

We need to validate the names, addresses and email address supplied by the customer via the Apple Sheet / Wallet to ensure they are compatible with our back-end system that cannot be changed to match Apple's less strict validation rules.


Example validation rules are max length on fields or certain characters not been allowed.


In onShippingContactSelected, we only get a partial / redacted address (as described in https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypayment/1916097-shippingcontact) so we can't fully validate all the fields at that point. We've been able to validate the shipping address country to confirm that it's domestic and show a red text error message if it's international but other fields such as address lines are not available at this point. We did this by using reject with STATUS_INVALID_SHIPPING_POSTAL_ADDRESS as follows:


      reject({
        status: 'STATUS_INVALID_SHIPPING_POSTAL_ADDRESS',

        newTotal: {
          label: this.client.getMerchantName(),
          amount,
          type: 'final',
        },
        errors: [
          new ApplePayError(
            'shippingContactInvalid',
            'country',
            'International shipping is not available'
          ),
        ],
      });


After the customer authorises the payment, we get access to the full data in onAuthorized. We're trying to show an error (ideally against a specific field(s) in the address(es)) but haven't managed to find a way to show any sort of custom error on the Apple Pay sheet after authorisation yet.


Do you know if this is possible, and if so, how to do it?


We've tried reject with STATUS_FAILURE and an array of ApplePayError but it's not showing us a specific error message (just a generic "payment not completed" error).

We also tried using STATUS_INVALID_SHIPPING_POSTAL_ADDRESS in onAuthorized but that showed the generic error as well.

  • Hi,

    Did you ever get the validation working properly?

    Having spoken to Adyen they’ve not implemented ‘ ’ApplePayError’

    https://developer.apple.com/documentation/apple_pay_on_the_web/applepayerror

    as they didn’t think it was a crucial feature.

    No idea why as posting back to the Apple Pay payment form that the address is invalid seems pretty critical to me.

    Did you find another pay to post error messages back to the Apple Pay payment form?

    Thanks

Add a Comment

Replies

Hi, Did you ever get the validation working properly? Having spoken to Adyen they’ve not implemented ‘ ’ApplePayError’ https://developer.apple.com/documentation/apple_pay_on_the_web/applepayerror%C2%A0as they didn’t think it was a crucial feature. No idea why as posting back to the Apple Pay payment form that the address is invalid seems pretty critical to me. Did you find another pay to post error messages back to the Apple Pay payment form? Thanks