Test cards
The four canonical sandbox PANs, and how to run an approval and a decline.
Sandbox card testing uses four PANs — one per network — entered on the hosted payment page. The PAN chooses which network processes the transaction. The amount chooses whether it approves or declines.
The four canonical cards
All expire 12/28. Use the CVV on the same row: each network has its
own approving value.
| Network | PAN | CVV |
|---|---|---|
| Visa | 4012000098765439 | 999 |
| MasterCard | 5146315000000055 | 998 |
| Discover | 6011000993026909 | 996 |
| Amex | 371449635392376 | 9997 |
Never send a PAN to the Cresora API. There is no card object on any
request body and a raw PAN is rejected with 400. Card data is typed
into the hosted page only.
Run an approval end to end
1. Create the session
curl -X POST https://api.sandbox.cresoracommerce.ai/api/v1/hpp/sessions \
-H "Authorization: Bearer $CRESORA_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"merchant_id": "<uuid>", "amount": "10.00", "currency": "USD"}'The response carries the page to open:
{
"hpp_url": "<open this URL in a browser>"
}2. Enter the values on the page
Open hpp_url, then type PAN 4012000098765439, expiry 12/28, CVV
999. Submit.
3. Read the outcome
Poll GET /hpp/sessions/{id}, or handle the hpp_session.completed
webhook, which carries the id as data.transactionId. When you poll, an
approval completes the session and fills in its transaction_id:
{
"state": "COMPLETED",
"transaction_id": "<uuid>"
}Read that transaction with GET /transactions/{transactionId}: its
state reads CAPTURED.
Run a decline end to end
Change one thing: the amount. Repeat the steps above with an amount of
0.20, a fresh Idempotency-Key, and the same card. A declined
attempt is, apart from rare anomalies, recorded as a FAILED transaction and emits
transaction.failed. The session stays PENDING, so the
payer can try again, and reading it still returns HTTP 200:
{
"state": "PENDING",
"last_attempt": { "at": "<timestamp>", "reason": "<reason for this attempt>" }
}An hpp_session.attempt_failed webhook also fires.
Card amount triggers
| Amount | Vendor scenario | Kind |
|---|---|---|
$10.00 | approved | — |
$0.01 | refer to issuer | CALL |
$0.05 | pick up card | hard, retain |
$0.07 | lost card | fraud, hard |
$0.20 | do not honor | decline |
This is a partial list. These rows are the canonical certification scenarios; the complete amount-to-outcome sheet is vendor-owned and larger. Test against the rows you need to certify.
Discriminating on the outcome
A decline is a business outcome, so the transport is a normal 200.
An approval completes the session, and its transaction reads
CAPTURED. A declined card attempt leaves the session PENDING with
last_attempt.reason set and, apart from rare anomalies, is also recorded as a FAILED transaction. Branch on the session's state for the
final outcome. While it reads PENDING, a last_attempt means a try was
declined and the payer can try again; report or route on its reason. A
PENDING session can also hold a payment whose outcome is unknown: if you
received hpp_session.payment_unresolved for it, do not ask the payer to
pay again, even after the session reads EXPIRED; contact Cresora support
with the session id. The session read does not show this, so subscribe to
hpp_session.payment_unresolved: polling alone cannot tell an unresolved
payment from an abandoned session.
Do not hard-code an amount-to-outcome mapping from this page.
The trigger amount selects the vendor scenario. Read
last_attempt.reason at runtime
and branch on what your integration actually gets.
Next: AVS and CVV for address and security-code results, and certification scenarios for the list you must cover before going live.