Receiving webhooks
Nine of the eighteen sandbox scenarios resolve asynchronously: the API answers immediately with PENDING, and the outcome arrives at your endpoint moments later. This includes every successful payin, every cancellation, and all six payout scenarios.
Without a webhook receiver you can only exercise the synchronous half of the catalog. Set one up first — it is the single highest-value thing you can do before writing integration code.
Setting up your endpoint
Requirements:
| Method | POST with Content-Type: application/json |
| Response | 200. Anything else is treated as a delivery failure |
| Reachability | Publicly reachable over HTTPS |
| Not allowed | localhost, 127.0.0.1, private IPv4 ranges (10/8, 172.16/12, 192.168/16), IPv6 link-local. Deliveries to private addresses do not happen, so point the URL at something reachable from the internet |
You pass the URL per request, in notificationUrl. Different requests can point at different endpoints, which is useful when several developers test in parallel against the same sandbox shop.
For a first run, a hosted request bin works and requires no code. Once you are past the quickstart, point notificationUrl at your real handler in a development environment — the whole point is to exercise the code that will run in production.
What arrives
There is no event envelope. A webhook is not a {eventType, entityId} wrapper around a status — it is the resource itself, in the same shape the API returns it, with the status updated. Correlate on the resource identifier.
Payin
The transaction object, with status at the root:
{
"uid": "a0017186-3ab1-733d-afad-5271d300032e",
"type": "payment",
"status": "APPROVED",
"message": "",
"amount": 17689,
"currency": "USD",
"description": "order-12345",
"createdAt": "2026-09-09T13:53:14.947Z",
"updatedAt": "2026-09-09T13:53:14.947Z",
"customer": { "...": "as sent" },
"billing": { "currency": "BRL", "amount": 100000 },
"paymentMethod": { "id": "...", "name": "PIX", "type": "Online" }
}uid is the same one you received in the synchronous response — that is your correlation key.
Two fields worth understanding, because they are not what a first read suggests:
billing is what you charged the customer. The root amount and currency are the settlement figure — what PayRetailers settles to you, in your settlement currency. In the example above, BRL 1,000.00 was charged and USD 176.89 settled. Reconcile customer-facing records against billing, your receivables against the root.
message is empty on success and carries the reason on failure — the same field that holds AMOUNT_INVALID on a synchronous rejection.
Payout
The payout object. Note the field names differ from payin — payoutId, and the status lives in statusTypeCode:
{
"payoutId": 200380,
"statusTypeCode": "ERROR",
"errorReason": "INVALID_ACCOUNT",
"beneficiaryFirstName": "Pedro",
"beneficiaryLastName": "TestPayoutInvalid",
"email": "[email protected]",
"currencyCode": "BRL",
"country": "BR",
"amount": 100000.0,
"externalReference": "SBX-1788962138355"
}errorReason is where the specific failure lives, and it is the field your code should branch on — all five payout failures share statusTypeCode: "ERROR".
Do not write one handler for both. Payins and payouts use different identifiers and different status fields; a generic webhook handler that looks for status will silently miss every payout.
Timing
| Scenario | Webhook | Delay |
|---|---|---|
APPROVED | payment_status → APPROVED | 5 s |
CANCELLED | payment_status → CANCELLED | 5 s |
THIRD_PARTY_NOT_ALLOWED | payment_status → CANCELLED | immediate |
| All six payout scenarios | payout_status → FINISHED or ERROR | 5 s |
Everything else in the catalog is synchronous and sends no webhook at all. Two cases deserve attention because they are easy to misread as a delivery problem:
PENDING never sends a webhook. It simulates a customer who starts a payment and never completes it. The payment stays PENDING indefinitely. If your integration waits for a webhook before releasing an order, this is the scenario that proves it does not hang forever.
Synchronous failures never send a webhook. FAILED and the whole IDENTITY_* family are decided in the response. Nothing follows.
Which scenarios send what is listed per scenario in Payin scenarios and Payout scenarios.
Webhooks are not signed in the sandbox
This release does not sign sandbox webhooks. There is no signature header to verify and no sandbox webhook secret is issued with your credentials.
This is a deliberate gap, and it has a consequence you need to plan for: your signature verification code cannot be tested here. If your handler rejects unsigned requests — as it should in production — it will reject every sandbox delivery.
Two ways to work with that:
- Make verification conditional on environment configuration, so it is enabled in production and skipped for sandbox deliveries. Keep the switch in configuration, never in a code branch you might forget to remove.
- Or test your handler's business logic against the sandbox, and validate signature verification separately against your first production webhooks.
Whichever you choose, treat signature verification as an item that leaves the sandbox untested. It belongs on your production go-live checks, not your sandbox checks — the same way document format validation does (see Quickstart).
Production webhooks are signed. Signature verification in the sandbox is planned for a future release.
Delivery failures and retries
If your endpoint does not return 200, the sandbox retries. The retry behaviour is the same as production, and it is already active in the sandbox today:
- Retries are triggered by any response other than
200. - Intervals grow exponentially between attempts.
- The maximum number of attempts is a configuration value, not a fixed constant.
- Deliveries that never succeed are logged for investigation.
Because the schedule is exponential and the attempt limit is configurable, do not hardcode retry timings or an expected attempt count in your tests. Assert that a redelivery arrives and that you handle it correctly — not that it arrives at a particular second. A test that pins exact intervals will break on a configuration change that is not a defect.
Retries are also how you test your own recovery path. Return a 500 from your handler on purpose, confirm the redelivery arrives, and confirm that when you finally return 200 you do not double-process the payment.
A practical note on that last point: build your handler to be idempotent on the resource identifier — uid for payins, payoutId for payouts. Retries mean the same outcome can reach you more than once, in the sandbox and in production.
When you cannot receive webhooks yet
Poll instead — but only as a stopgap while your receiver is being built.
sleep 6
curl "https://sandbox.payretailers.com/payments/v2/transactions/$UID" \
-H "Accept: application/json" \
-H "Ocp-Apim-Subscription-Key: $SUBSCRIPTION_KEY" \
-u "$SHOP_ID:$SECRET_KEY"Wait at least six seconds. Polling immediately after the POST returns the initial PENDING, which is not the outcome.
Polling does not apply to synchronously-resolved scenarios. FAILED and the IDENTITY_* family are already final in the response you received — there is no later state to discover, and retrieving them afterwards is not supported.
Testing your webhook handling properly
A sequence that covers the paths that actually break in production:
- Happy path —
APPROVED, handler returns200, order released once. - Negative outcome —
CANCELLED, confirm you do not release the order. - No webhook —
PENDING, confirm nothing hangs and no timeout fails the order incorrectly. - Immediate delivery —
THIRD_PARTY_NOT_ALLOWED, which arrives with no delay. Confirm you handle a webhook that lands before your own transaction record is committed. - Delivery failure — return
500once, confirm you process the retry correctly. - Duplicate delivery — process the same
uidtwice, confirm one side effect.
Step 4 is worth singling out. A zero-delay webhook can reach your endpoint before your code has finished writing the payment it refers to. It is a real production race condition, and the sandbox lets you reproduce it on demand.
Next
- Payin scenarios — all 12 outcomes.
- Payout scenarios — all 6 outcomes.
- Production realism by country — which outcomes, and therefore which webhooks, your market actually produces.
Updated about 8 hours ago