Skip to content
Developer
Sign inSign up

Test your integration

Test your integration with small real payments, signed test events and requests that fail on purpose.

Ask AI about this page

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

WhatHow
Creating paymentsCreate a small real payment from your server and open its url.
Each outcomePay in full, short, over or not at all (below).
Your webhook handlerSend a test event of any type, then resend real deliveries.
RetriesCreate the same payment twice with the same reference: you get one payment.
ErrorsSend 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.

OutcomeHowEvent
SucceededPay the full amount.payment.succeeded
UnderpaidSend less than checkout asks for, by more than your 0.5% tolerance.payment.underpaid
OverpaidSend more than checkout asks for.payment.overpaid
ExpiredSet expires_at 15 minutes out and don't pay.payment.expired
CanceledCancel 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-deliveries shows 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.

SendGet
A request with no key401 unauthenticated
amount as a JSON number, such as 49400 invalid_request
A used reference with a different amount409 reference_in_use
An ID that isn't yours404 not_found

Every code is on the errors page.

Next steps