KVNA
KVNA

Reputation: 907

What does a Square nonce represent?

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?

Upvotes: 4

Views: 7632

Answers (4)

Chirag jain
Chirag jain

Reputation: 1

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.

Upvotes: 0

Robert Bolton
Robert Bolton

Reputation: 673

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.

Upvotes: 1

Ken Gant
Ken Gant

Reputation: 11

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 :-)

Upvotes: 0

tristansokol
tristansokol

Reputation: 4271

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.

Upvotes: 5

Related Questions