Credit card issue

If you have the submitted card token (coming from the form) and use it for a transaction, you can then use the payment ID to save the customer credit card. That’s documented here - though haven’t checked the js version of the doco:

To explain further, if you want to do BOTH a transaction AND save the card, you can do it in either order:

  1. create saved card using form token, then use saved card token (cnon:…) for transaction, OR
  2. do payment transaction using form token, then use payment ID to save card (as above).

The documentation is your friend here; try it out in API Explorer if you’re not sure what returns what.

I haven’t checked it, but I think BOTH of these will return the last 4 digits - see Bryan’s example above. But the real answer here is to do some playing with the API Explorer, it makes understanding things much easier when you can see them in black and white!

The doco for saving the card first is: https://developer.squareup.com/docs/cards-api/walkthrough-seller-card

I’m a bit at sea here as it looks like you’re using the Javascript version of the API, and I use the PHP version, so I’m essentially guessing here; though the key is just to do a call in the sandbox and see what it returns and/or use the API Explorer. Bryan - if I have anything wrong, please correct me!

If you’re using Javascript, always check the JS console for errors, which appear there otherwise silently.

Cheers,

Brian

1 Like