Search code examples
square-connectsquare

How to generate card nonce for repeated transactions without making users to enter card details?


We have a requirement that payment should be initiated repeatedly without user's intervention just like monthly/yearly subscription fees for Mobile Apps in Google Play store . The payment should be triggered from the back end automatically after a particular interval (amount may not be same for every interval). We found that in square payment card nonce is used for performing a transaction. Card nonce is generated from the Payment form when the users enter their card information for the first time. How to generate the nonce for further transactions without making users to enter their card details in square payment form?


Solution

  • You would want to utilize the Card on File functionality. Basically, the first time a customer enters their credit card details in the Square Payment Form, you would generate a nonce, and then use the nonce to save the card to a customer's profile (so you would of course need to create a Square customer as well). In the future, you would be able to charge the card on file, rather than making them enter their card details again.

    Details around saving cards on file with Square: https://docs.connect.squareup.com/payments/transactions/cookbook/save-cards-on-file

    Details around charging charges on file with Square: https://docs.connect.squareup.com/payments/transactions/cookbook/charge-cards-on-file

    Details around the CreateCustomerCard endpoint: https://docs.connect.squareup.com/api/connect/v2#endpoint-customers-createcustomercard