Testing

Sandbox Test Values

Test Square API operations in the v2 Sandbox.

Sandbox test values are used to test the client and server sides of payment processing in the Square v2 Sandbox.

Note

For information about test values for the deprecated legacy Sandbox, see Legacy Sandbox Test Values.

Sandbox payments
Permalink Get a link to this section

Square platform clients such as the payment form and In-app Payment apps accept payment cards and return one-time use encrypted "nonces" to be submitted to Square API payment endpoints to take payments. You can avoid testing your code with a real payment card by testing in the v2 Sandbox.

Test client-side card-present logic in your payment form or In-App Payment app by using test credit card numbers to generate nonces for use with the Square API payments and card on file endpoints in the sandbox.

If you do not need to test your client-side nonce-generation logic, use the nonces provided in the Square endpoint testing section to submit payments in the sandbox with test nonces.

Client-side testing
Permalink Get a link to this section

You can use test credit cards with the payment form and In-AppPayments SDK to input card numbers that will generate a testable payment nonce.

Card present success state values
Permalink Get a link to this section

The sandbox supports a collection of credit card numbers for all Square-supported card brands for simulating the client-side of payment scenarios.


Test cards

BrandNumberCVVVerification Code
Visa4111 1111 1111 1111111
Visa EU4310 0000 0020 1019111123456
MasterCard5105 1051 0510 5100111
MasterCard EU5500 0000 0020 1016111123456
Discover6011 0000 0000 0004111
Discover EU6011 0000 0020 1016111123456
Diners Club3000 0000 0000 04111
JCB3569 9900 1009 5841111
American Express3400 000000 000091111
American Express EU3700 000002 010141111123456
China UnionPay6222 9888 1234 0000123

Notes:

  • You can set the card expiration date to any future month and year.

  • Payments in USD (United States), CAD (Canada), or GBP (United Kingdom) also require a valid postal code.

  • When testing the SCA flow with one of the European Union test cards, the Verification Code simulates the SMS verification code sent to the buyer mobile phone during an actual transaction.

Error state values
Permalink Get a link to this section

You can reproduce certain error states in the sandbox by providing special values in the Square payment form or In-App Payments SDK.

If you use one of the following values, the nonce returned will trigger an error when it is processed by the CreatePayment endpoint:

Desired error stateTest values
Card CVV incorrectCVV: 911
Card postal code incorrectPostal code: 99999
Card expiration date incorrectExpiration date: 01/40
Card declined numberCard number: 4000000000000002
Card on file auth declinedPAN: 4000000000000010

SCA testing in the payment form
Permalink Get a link to this section

To test SCA in the sandbox, you cannot use a nonce returned by the payment form in the cardNonceResponseReceived event after entering sandbox credit card numbers or personal credit card numbers. Instead, use a test nonce from the following table.

Use the SqPaymentForm.verifyBuyer function for card present and card on file (CoF) SCA challenges with the following test values:

API Call
Parameter
ValueVerification code
SqPaymentForm.verifyBuyer
(present)
sourcecnon:card-nonce-requires-verification123456
SqPaymentForm.verifyBuyer
(CoF)
sourceccof:customer-card-id-requires-verification123456

The SCA flow requires that the buyer provides a code sent to their mobile phone in an SMS message. When testing in the sandbox use the Verification Code to simulate the code sent via SMS.

Important

When testing the SCA flow in v2 Sandbox, be sure to initialize SqPaymentForm with a UK location ID.

The SCA flow and these test values are not supported in the legacy sandbox.

Square API endpoint testing
Permalink Get a link to this section

Test your payments logic that uses the CreatePayment endpoint to take a payment or CreateCustomerCard endpoint to store a customer card on file.

If you are using the Square Payments API to generate payments in the sandbox, you can use one of the sandbox test nonces as the source_id in the payment request.

Note: You can also use a nonce generated with one of the test payment cards from the Client-side testing section.


Sandbox test nonces

API operationFieldValue
Payments.CreatePayment
(card)
source_idcnon:card-nonce-ok
Payments.CreatePayment
(card on file)
source_idccof:customer-card-id-ok
Customers.CreateCustomerCardcard_nonce
billing_address.postal_code
cnon:card-nonce-ok
94103

Note

If you use a sandbox test nonce in the CreateCustomerCard operation, you must provide "94103" as the postal code in the billing_address field or the request will fail and return an with an invalid postal code error.

Generating error states
Permalink Get a link to this section

You can reproduce certain error states in the Square payment and card on file endpoints by using the following test values.

Error stateCreatePayment endpointCreateCustomerCard endpoint
Bad CVVcnon:card-nonce-rejected-cvvccof:customer-card-id-rejected-cvv
Bad postal codecnon:card-nonce-rejected-postalcodeccof:customer-card-id-rejected-postalcode
Bad expiration datecnon:card-nonce-rejected-expirationccof:customer-card-id-rejected-expiration
Card declinedcnon:card-nonce-declinedccof:customer-card-id-declined
Card nonce already usedcnon:card-nonce-rejected-cvvN/A

Sandbox locations
Permalink Get a link to this section

Your sandbox account comes with 1 mock location per application. This location is unrelated to the production locations listed in the Square Dashboard

The sandbox location ID for a given application is listed on the Locations tab of the application control panel in the Application Dashboard. You can also fetch the location ID programmatically by calling ListLocations with a sandbox access token.

Sandbox disputes
Permalink Get a link to this section

Use these predefined payment amounts that map to a specific dispute reason. When you set one of these amounts in a CreatePayment request, Square generates a sandbox dispute with the corresponding reason.

The amounts shown are in the lowest denomination of the currency you provide in the CreatePayment request. For example, for USD, the amount is in cents.

Charge amountDispute reason
8801AMOUNT_DIFFERS
8802CANCELLED
8803DUPLICATE
8804NO_KNOWLEDGE
8805NOT_AS_DESCRIBED
8806NOT_RECEIVED
8807PAID_BY_OTHER_MEANS
8808CUSTOMER_REQUESTS_CREDIT
8809EMV_LIABILITY_SHIFT