4

I am trying to submit a payment to Square, and am not sure what the card_nonce represents.

In the full API Documentation found here: https://docs.connect.squareup.com/api/connect/v2/#endpoint-createcustomercard

It states, "A card nonce representing the credit card to link to the customer."

However, in the REST payment processing documentation found here: https://docs.connect.squareup.com/articles/processing-payment-rest

It states, "Card nonces expire after 24 hours. The Charge endpoint returns an error if you attempt to charge an expired nonce."

  1. If I am trying to store a card_nonce for recurring billing can I use a card_nonce one time and repeatedly use it for billing?

  2. Will a customer have to enter their card information every time they want to check out?

  3. Does a card_nonce represent the state of the card, or a key that represents a specific card transaction?

5
  • "Card nonces are generated by the SqPaymentForm that buyers enter their card information into. See Embedding the payment form for more information." so it's a String that is generated by the form. That's all.
    – user4616966
    Commented May 10, 2017 at 21:04
  • I'm not a square expert but yes, I think that the user would have to re-enter their CC details again in this scenario. I don't know if square provides a way to save details on a server.
    – adam-beck
    Commented May 10, 2017 at 21:05
  • Can I use the SqPaymentForm to add a card to a customer profile?
    – KVNA
    Commented May 10, 2017 at 21:06
  • Yes but I think only the non-confidential details of a card. Which is why a nonce would need to be generated each time.
    – adam-beck
    Commented May 10, 2017 at 21:07
  • @adam-beck There is a section in the customer dashboard directory to add a card to a customer's profile.
    – KVNA
    Commented May 10, 2017 at 21:08

4 Answers 4

5

A card nonce is a tokenized form of a credit card. You can use it only once, and they do expire. It "represents" a credit card, and all the details that a end user typed into your payment form.

If you want to use it for reocurring payments, please read the Processing reoccurring payments in Square's documentation.

You attach the card to a customer, and then use the the customer's card id against charge endpoint for payments without end users having to input their credit card details again.

10
  • OK, so when making a checkout flow, the card_nonce can be used for either processing a payment or connecting to the CreateCustomerCard endpoint, but not both at the same time? i.e. A new customer will have to fill out a separate form to add a card on file?
    – KVNA
    Commented May 10, 2017 at 22:10
  • correct, every new customer needs to to fill out the form at least once. Commented May 10, 2017 at 22:11
  • So typically do you see design patterns where an application has one button to add card on file and a separate button for one time payment?
    – KVNA
    Commented May 10, 2017 at 22:13
  • And does the submit button on the form consume the card_nonce during the cardNonceResponseReceived callback?
    – KVNA
    Commented May 10, 2017 at 22:15
  • in general your applications do only one kind based on their use case. The design is usually to just ask customers if they want to keep their card on file and just process it differently in the back end. two buttons would be kind of weird. The card nonce is only "consumed" when you send it to one of our endpoints, or it expires. Commented May 10, 2017 at 22:16
1

Per the Square documentation (link below) you can use either value below for nonce. Make sure you are using your sandbox credentials for testing.

fake-card-nonce-ok — returns a successful test transaction.
fake-card-nonce-declined — returns a "Card Declined" error.

e.g. - Replace nonce below with either "fake-card-nonce-ok" or "fake-card-nonce-declined".

ChargeRequest body = new ChargeRequest(AmountMoney: amount, IdempotencyKey: uuid, CardNonce: nonce);

https://docs.connect.squareup.com/articles/using-sandbox

This will return a JSON object with transaction result information.

0

Also not a Square developer, but the use of the term "nonce" seems to imply the answers to your questions. Basically, a nonce would normally be a one-use authentication token or one-time key. So ...

  1. By definition, a nonce wouldn't be useful for anything recurring.

  2. Yes, the customer would need to re-enter information each time.

  3. The card_nonce would likely represent a singular authentication of that card.

Of course, if they define it differently, my answers could be all off :-)

0

To Generate a card_nonce / payment token - Use the Web Payments SDK client library to render a payment entry form and generate a payment token/card nonce that your web client sends to your backend server, Store that card_nonce and Now to make payment , Call API CreatePayment and pass card_nonce as source_id.

card nonce is a tokenized form of your credit card.It is also used when you want to Create card on file , passed this card_nonce as source-id.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.