402pay has no test mode, test keys or test cards: every payment is real. Test with small payments you make yourself, signed test events and replays of real deliveries.
A crypto test costs little: the money lands in your own wallet, so you're out only the network's fee and any fee 402pay charges.
What to test
| What | How |
|---|---|
| Creating payments | Create a small real payment from your server and open its url. |
| Each outcome | Pay in full, short, over or not at all (below). |
| Your webhook handler | Send a test event of any type, then resend real deliveries. |
| Retries | Create the same payment twice with the same reference: you get one payment. |
| Errors | Send requests that fail on purpose (below). |
Test payments
- Use a restricted key for your test environment, with only the access it needs, and revoke it when you're done.
- Amounts start at the equivalent of $1.00, so keep tests small.
- Pay with a stablecoin on a network with low fees. A card test is a real card payment: the customer verifies their identity with the card provider, and it arrives as crypto.
- Cancel any payment you create and don't pay.
Cause each outcome
Every outcome is something real you do to a payment. Watch for its event.
| Outcome | How | Event |
|---|---|---|
| Succeeded | Pay the full amount. | payment.succeeded |
| Underpaid | Send less than checkout asks for, by more than your 0.5% tolerance. | payment.underpaid |
| Overpaid | Send more than checkout asks for. | payment.overpaid |
| Expired | Set expires_at 15 minutes out and don't pay. | payment.expired |
| Canceled | Cancel it with POST /payments/{id}/cancel. | payment.failed |
An underpaid payment is the one to rehearse: see underpayments for requesting the rest or accepting what arrived.
Test webhooks
A test event is signed like a real one and changes nothing in your business. Its payload has test: true and a subject ID containing _test_, and it goes out once, without retries.
Send a test event
curl -X POST "https://api.402pay.co/api/v1/webhooks/whk_GFAKLrE8wkBwF4WL/test" \ -H "Authorization: Bearer $PAY402_SECRET_KEY" \ -H "Content-Type: application/json" \ -d '{ "event_type": "payment.succeeded" }'- Endpoints must be public
https://addresses. To reach your machine, use an HTTPS tunnel, or replay deliveries locally. - Resend a real delivery to check that your handler skips one it has already processed.
GET /webhook-deliveriesshows each request and your server's response.- Test events and resends are limited to 10 a minute for each business.
Test errors
These requests fail on purpose, so you can check how your code handles each one.
| Send | Get |
|---|---|
| A request with no key | 401 unauthenticated |
amount as a JSON number, such as 49 | 400 invalid_request |
A used reference with a different amount | 409 reference_in_use |
| An ID that isn't yours | 404 not_found |
Every code is on the errors page.