How to detect apple pay token with expired card

Hi All,

We are following the standard apple pay process with web payment sdk, which is to use Square web payments sdk to call Apple Pay on iPhone to get a Square token, and then use this token to call Square payment API to create the payment.

However we noticed sometimes the apple pay may be with a expired card, which we can know it only at the stage of calling Square payment API with the token, is there any way to detect it on iPhone? such like, identifying the apple pay is with an expired card while Square web payment sdk generating the token.


:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

In-App Payments SDK: How It Works
Payment API: Process Online and In-Person Payments
Download, Configure, and Run the Client Sample

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

The Square Web Payments SDK and In-App Payments SDK perform client-side validation on card entry fields, such as an improper credit card number length, a wrong expiration date format, an incomplete ZIP code, and a non-credit-card number. However, if credit card details are entered in the card form in a correct format but specific field values are wrong (such as an invalid expiration date or invalid card number), the card still passes the client-side validation but fails when the payment is actually attempted.

In your case, when using Apple Pay, the card details are managed by Apple Pay and the Square SDKs only receive a token representing the card details. Therefore, the SDKs cannot perform any validation on the card details, including checking the expiration date.

The validation of the card details, including the expiration date, is performed when you attempt to create a payment using the Square Payments API. If the card is expired, the API will return an error.

So, unfortunately, there is no way to detect an expired card at the time of generating the token with Apple Pay on the client side. The card expiration validation happens on the server side when you attempt to process the payment.

This answer was reviewed by @Bryan-Square.