Taking payment and then saving the card against a Square Id

Hi there, with the new Web Payments SDK is there any documentation on taking a card payment and storing the card against the users account on Square if they want to store the card for future purchases? At the moment we use the Verification Token, call the Create Customer Card to store the card and then we try and create a payment request and charge the card on file. Is this the recommended approach?

Further to this question we just found the CreateCardRequest in the API. We have tried the following:

  1. Creating a CHARGE request and calling the CreatePayment method on the payments API
  2. On success creating a CreateCardRequest passing in the CreatePaymentResponse payment id

This seems to work on test cards that do not require a Verification Code. For all cards that require a verification code, when we try and store the card we get back the following error:

{Error : (this.Category = INVALID_REQUEST_ERROR, this.Code = INVALID_CARD_DATA, this.Detail = Invalid card data., this.Field = source_id)}

This happens for all test cards that require SCA.

Will this be an issue when we go live or is it something in the test API. Is this also best practice to process a transaction and store the associated card against the customers Square Id?

When you make the CreateCard request with the payment_id are you calling verifyBuyer with the payment_id with the intent to store? :slightly_smiling_face:

Hi Bryan, thanks for your response. We are doing this through the back end API. So we set the intent to CHARGE on the frontend and then call Create Payment in the backend API to get the payment through otherwise it would fail with the wrong intent if we selected STORE. We then call CreateCardRequest using the returned payment id to create the card. This works for all cards that don’t require SCA, the transaction goes through and the card is stored, but for all transactions that require SCA we get that error message above.

We wouldn’t be able to use STORE, save the card and then create a transaction right?

Right, however you will need to call verifyBuyer again with the payment_id with the intent to STORE when saving the card on file. This is because the verification token is a one time use token.

So there is no way to charge a card and store it at the same time? The user journey would be so odd. I take the payment and charge it, then ask them to enter the details again so I can store it?

Yeah, at this time that is the way it has to be done with SCA. :slightly_smiling_face:

Ah ok, thanks for letting me know. I would think the best user journey is to charge the user, try and save the card, if it fails then tell the user on the confirmation screen that their card details couldn’t be saved and ask them to add their card details there if they want to store them and then use the STORE method.

Yeah, that is definitely one customer experience that is possible. :slightly_smiling_face:

What I do is to save the card first, then make the payment against the stored card, rather than charge it then store it. I haven’t had any issues with that so far.

1 Like