Guide
Test mode and going live
Build against sk_test_, then switch keys with a checklist.
Build against test mode
Your test key (sk_test_…) creates test payments (ids start with tt_) that never touch your balance. Create them exactly as you would live, then drive them to any outcome with payment/test-complete:
# 1) create a test payment with your sk_test_ key
curl -X POST https://cryptopayr.com/api/v1/payment/create \
-H "Authorization: Bearer sk_test_xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"amount":19.99,"currency":"USD","webhook_url":"https://shop.example/hook"}'
# 2) drive it to the event you want to test
curl -X POST https://cryptopayr.com/api/v1/payment/test-complete \
-H "Authorization: Bearer sk_test_xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"tid":"tt_…","status":"COMPLETED"}'$test = new \CryptoPayr\Client(['api_key' => 'sk_test_xxxxxxxxxxxxxxxxxxxxxxxx']);
$p = $test->payments->create([
'amount' => 19.99, 'currency' => 'USD', 'webhook_url' => 'https://shop.example/hook',
]);
$test->request('POST', 'api/v1/payment/test-complete', ['tid' => $p['tid'], 'status' => 'COMPLETED']);const test = new CryptoPayr({ apiKey: 'sk_test_xxxxxxxxxxxxxxxxxxxxxxxx' });
const p = await test.payments.create({
amount: 19.99, currency: 'USD', webhook_url: 'https://shop.example/hook',
});
await test.request('POST', 'api/v1/payment/test-complete', { tid: p.tid, status: 'COMPLETED' });test = Client(api_key="sk_test_xxxxxxxxxxxxxxxxxxxxxxxx")
p = test.payments.create({
"amount": 19.99, "currency": "USD", "webhook_url": "https://shop.example/hook",
})
test.request("POST", "api/v1/payment/test-complete", {"tid": p["tid"], "status": "COMPLETED"})Run through every outcome your code handles: COMPLETED, UNDERPAID, EXPIRED, CANCELLED and REFUNDED (with refund_amount for a partial refund). Send the same refund_id twice to check that your handler ignores a repeat. You can also try it from the docs.
"test": true and an X-CryptoPayr-Test: true header. Only payment/create, payment/lookup and payment/test-complete accept the test key.Before you switch to live
- Your webhook handler checks the
X-CryptoPayr-Signatureheader against the raw body. - It fulfils only on
COMPLETED, and handlesunderpaidthe way you decided. - It ignores a
tidit has already fulfilled, and keys refunds onrefund_id. - It answers
200within 15 seconds. - A job re-checks waiting orders with
payment/lookup, in case a webhook was missed. - Every create call sends an
Idempotency-Key. - Your keys are in server-side config, not in the browser or the repository.
- The withdrawal key (
wk_live_…) is only on the server that sends payouts, if you send any. - Your
webhook_urlis a publichttps://address on port 443.
Switch the keys
Replace sk_test_… with sk_live_… in your config, and verify webhooks with the live key. Then make one small real payment yourself to check the whole path end to end, and refund it from the dashboard if you like.
After launch, watch Dashboard → Webhooks for failed deliveries for the first few days.