Test your integration

Test your front-end payment flows, and transaction lifecycle requests.

Testing the Payments API

When testing Primer's Payments API, we have a special Primer Test Processor connection which is ready for use on your Sandbox account when you first log in. We have a series of test tokens you can use with the Primer Test Processor to elicit a variety of status responses. Learn more about statuses in Managing payments.

Testing authorization scenarios

Pass in a test token in the paymentInstrument field during payment creation to test various transaction statuses.

Test TokenScenarioTransaction Status
tok_auth_authorized_cardThe payment was authorized by the processor. This will put the transaction into an authorized state.Authorized
tok_auth_declined_cardThe payment was declined by the processor, either at a gateway or acquirer level.Declined
tok_auth_failed_cardPrimer failed to get a response from the chosen processor, it may be down or otherwise unavailable.Failed
tok_auth_settled_cardThe payment was authorized and subsequently settled by the processor.Settled

Testing AVS and CVV scenarios

The test tokens described above can also be used in conjunction with special test amounts. Pass in a test amount in the amount field to test different AVS and CVV check scenarios.

AmountScenarioRisk Data Attribute in ResponseAttribute Value
1-99AVS postal code check passed.avsPostalCodeMATCHED
100-199AVS postal code check failed.avsPostalCodeNOT_MATCHED
200-299AVS postal code check not supplied. No check performed.avsPostalCodeNOT_PROVIDED
300-399AVS street address check passed.avsStreetAddressMATCHED
400-499AVS street address check failed.avsStreetAddressNOT_MATCHED
500-599AVS street address check not supplied. No check performed.avsStreetAddressNOT_PROVIDED
600-699CVV check passed.cvvMATCHED
700-799CVV check failed.cvvNOT_MATCHED
800-899CVV not supplied. No check performed.cvvNOT_PROVIDED

The example below would return an authorized payment with a failed AVS check on the postal code:

1
2
3
4
5
6
7
8
9
10
11
12
curl --location --request \
POST 'https://api.sandbox.primer.io/payments' \
--header 'X-API-KEY: <YOUR_API_KEY>' \
--header 'IDEMPOTENCY_KEY: order-123' \
--data '{
"amount": 100, # use a test amount here
"currencyCode": "EUR",
"orderId": "order-123",
"paymentInstrument": {
"token": "tok_auth_authorized_card", # use a test token here
},
}'
curl

Testing 3D Secure

Scenarios

To test 3D secure, specify one of the values referenced below within the testScenario field.

test scenario valueScenario3D Secure Authorization Response3D Secure Verification Response On Challenge
3DS_V2_FRICTIONLESS_SUCCESS3DS v2 successful authentication without challengeAUTH_SUCCESSN/A
3DS_V2_FRICTIONLESS_FAIL3DS v2 failed authentication without challengeAUTH_FAILEDN/A
3DS_V2_CHALLENGE_SUCCESS3DS v2 successful authentication after challengeCHALLENGEAUTH_SUCCESS
3DS_V2_CHALLENGE_FAIL3DS v2 failed authentication after challengeCHALLENGEAUTH_FAILED
3DS_V2_NOT_AVAILABLE3DS v2 skipped - not available from the issuerSKIPPEDN/A
3DS_V1_SUCCESS3DS v1 successful authenticationCHALLENGEAUTH_SUCCESS
3DS_V1_FAIL3DS v1 failed authenticationCHALLENGEAUTH_FAILED
3DS_V1_NOT_AVAILABLE3DS v1 skipped - not available from the issuerSKIPPEDN/A

Example usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// client.js
window.addEventListener("load", onLoaded);
async function onLoaded() {
const clientTokenResponse = await fetch("/client-token", {
method: "post",
headers: { "Content-Type": "application/json" },
});
const { clientToken } = await clientTokenResponse.json();
const primer = new Primer({
credentials: {
clientToken, // Your server generated client token
},
});
/**
* For Universal Checkout, add testScenario to the threeDSecure options:
*/
primer.checkout({
container: "#checkout-container",
threeDSecure: {
// Choose a test scenario
testScenario: "3DS_V2_CHALLENGE_SUCCESS",
// Provide your order information as normal
order: myThreeDSOrderInfo,
additionalInfo: moreCustomerInformation,
},
});
/**
* For Checkout Components, add the testScenario to the 3ds verify call:
*/
primer.threeDSecure.verify({
// Choose a test scenario
testScenario: "3DS_V2_CHALLENGE_SUCCESS",
// Provide your order information and token as normal
token: myUnauthenticatedToken,
order: myThreeDSOrderInfo,
additionalInfo: moreCustomerInformation,
});
}
js