Docs · Webhooks

Webhooks

Get told when you're paid

Once an order is confirmed as paid, PayerNex sends your server a signed JSON POST. Check the signature, look the order up again, mark your invoice paid once, and reply with any 2xx.

Two ways to get notified #

Order IPN (callback)Webhook endpoints
Set up inipn_url on each order, or Dashboard → Developer → Callback URLDashboard → Webhooks → + Add Endpoint (as many as you need)
Eventspayment.completed, payment.disputedorder.paid, order.review, order.expired, order.refunded, payment.disputed, invoice.paid, transaction.unclaimed (choose per endpoint)
Signed withYour account Webhook Secret (Dashboard → Developer)That endpoint's own signing secret (Dashboard → Webhooks → Show signing secret)
Signature headerX-SignatureX-PayerNex-Signature
Event headerX-Webhook-Event: payment.completedX-PayerNex-Event: order.paid or transaction.unclaimed
Used byThe WooCommerce and Dhru Fusion plugins, and most custom integrationsExtra systems such as your backend, n8n, Zapier or Slack relays

The two work independently. When an order is paid, PayerNex first sends order.paid to every active endpoint subscribed to it, then sends the order IPN. You can use one, the other, or both.

Which URL is notified #

For the order IPN, PayerNex picks the first URL that is set, in this order:

  1. The order's ipn_url, sent with create-order. This is the recommended option, and every official plugin uses it.
  2. The callback URL on a shared gateway. This applies when the order was paid through a gateway another merchant shared with you and you saved a callback URL for that share.
  3. Your account Callback URL in Dashboard → Developer.

If none of these is set, no order IPN is sent, though webhook endpoints still receive order.paid.

Payload #

POST your-ipn-url · Content-Type: application/json
{
  "event": "payment.completed",
  "order_ref": "ORD-9F2C61D04B7A3E58",
  "amount": 25,
  "paid_amount": 25,
  "currency": "USDT",
  "paid_currency": "USDT",
  "status": "paid",
  "transaction_id": "432459971637714944",
  "binance_internal_id": "P_A214MP961HN71116",
  "binance_order_no": "432459971637714944",
  "customer_id": "user_1042",
  "customer_email": "[email protected]",
  "description": "Invoice #1042",
  "fee_charged": 0,
  "paid_at": "2026-10-25T10:14:03.000Z",
  "created_at": "2026-10-25T10:02:41.000Z"
}
FieldTypeDescription
eventstringAlways payment.completed.
order_refstringThe order's ID. Use it to find your invoice and to call GET /api/v1/order/{order_ref}.
amount, currencynumber, stringWhat the order asked for.
paid_amount, paid_currencynumber | null, string | nullWhat was actually received. This can be in another currency, for example PKR for a bank transfer.
statusstringAlways paid. No webhooks are sent for other statuses.
transaction_idstringThe best payment reference available, in this order: blockchain transaction hash, then the Binance order number the buyer sees in their app, then the Binance internal pay ID, then a manual transaction ID entered in the dashboard. If none exists, it is the order_ref.
binance_internal_id, binance_order_nostring | nullBinance Pay IDs. They are null for other payment methods.
customer_id, customer_email, descriptionstring | nullThe values you sent with create-order.
fee_chargednumberFee PayerNex recorded on the order. It is usually 0.
paid_at, created_atstringISO 8601 UTC timestamps.
cardobjectOnly for card (Stripe) payments: brand, last 4, card country, funding, wallet, 3D Secure result and version, liability_shift, Radar risk and CVC check. Same object as the order API's card. Other payment methods don't have this field.

Amounts are plain JSON numbers, so 25 is sent as 25, not 25.00. Don't rebuild the body yourself to check the signature. Hash the raw bytes you received.

Headers & signature #

Request headers (order IPN)
Content-Type: application/json
Accept: application/json
X-Signature: 3f1c…e9a0            # 64 lowercase hex chars
X-Webhook-Event: payment.completed
  • Algorithm: HMAC-SHA256, written as lowercase hexadecimal (64 characters). There is no sha256= prefix.
  • Key: your Webhook Secret, a 64-character hex string. Use it exactly as shown. Don't hex-decode it.
  • Signed bytes: the entire raw request body, exactly as received (UTF-8 JSON). Nothing else is signed: no timestamp, URL or headers.
  • Compare using a constant-time function (hash_equals in PHP, crypto.timingSafeEqual in Node).

No timestamp is signed, so the signature alone can't stop someone replaying an old valid request. Make your handler idempotent by marking each order_ref as paid once. Before fulfilling, also check the order with GET /api/v1/order/{order_ref} and make sure its status is paid.

Verify a webhook #

Both examples handle the order IPN. For a webhook endpoint, read X-PayerNex-Signature and use that endpoint's signing secret instead. The cURL tab sends a correctly signed test request to your own handler.

<?php
// payernex-webhook.php
$secret    = getenv('PAYERNEX_WEBHOOK_SECRET');      // Dashboard → Developer → Webhook Secret
$raw       = file_get_contents('php://input');       // exact bytes PayerNex sent
$signature = $_SERVER['HTTP_X_SIGNATURE'] ?? '';

$expected = hash_hmac('sha256', $raw, $secret);      // lowercase hex
if ($raw === '' || !hash_equals($expected, $signature)) {
    http_response_code(401);
    exit('invalid signature');
}

$event = json_decode($raw, true);
if (($event['event'] ?? '') !== 'payment.completed') {
    http_response_code(200);                          // acknowledge and ignore
    exit('ignored');
}

// Recommended: confirm with the API and trust ITS amounts, not the webhook's.
$ch = curl_init('https://payernex.com/api/v1/order/' . rawurlencode($event['order_ref']));
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 10,
    CURLOPT_HTTPHEADER     => ['Authorization: Bearer ' . getenv('PAYERNEX_API_KEY')],
]);
$order = json_decode((string) curl_exec($ch), true)['data'] ?? null;

if (!$order || $order['status'] !== 'paid') {
    http_response_code(409);
    exit('not paid');
}

// Look up YOUR invoice by $order['order_ref'] and mark it paid only once:
// if (invoice_already_paid($order['order_ref'])) { http_response_code(200); exit('ok'); }
// mark_invoice_paid($order['order_ref'], $order['paid_amount'], $order['paid_currency'], $event['transaction_id']);

http_response_code(200);
echo 'ok';

Common mistakes: hashing a re-encoded body such as json_encode(json_decode($raw)) or JSON.stringify(req.body) after express.json(), using the API key instead of the Webhook Secret, or using the account secret for an endpoint delivery.

Webhook endpoints #

In Dashboard → Webhooks you can add any number of endpoints. Each one has a URL, an optional label (up to 100 characters), the events it subscribes to, and an on/off switch. PayerNex generates a 64-hex-character signing secret for each endpoint, which you can reveal from the endpoint row. The Recent Deliveries table lists every attempt and the HTTP status that came back.

Request headers (webhook endpoint)
Content-Type: application/json
X-PayerNex-Signature: 9b04…7c1d   # HMAC-SHA256(raw body, endpoint secret), lowercase hex
X-PayerNex-Event: order.paid

The signature works the same way as X-Signature above. Only the header name and the key are different.

Events #

order.paid

Sent when an order becomes paid. The body has the same fields as the order IPN payload, plus delivered_at.

The body's event field and the X-PayerNex-Event header both carry the event name.

order.paid body
{
  "event": "order.paid",
  "order_ref": "ORD-9F2C61D04B7A3E58",
  "amount": 25,
  "paid_amount": 25,
  "currency": "USDT",
  "paid_currency": "USDT",
  "status": "paid",
  "transaction_id": "432459971637714944",
  "binance_internal_id": "P_A214MP961HN71116",
  "binance_order_no": "432459971637714944",
  "customer_id": "user_1042",
  "customer_email": "[email protected]",
  "description": "Invoice #1042",
  "fee_charged": 0,
  "paid_at": "2026-10-25T10:14:03.000Z",
  "created_at": "2026-10-25T10:02:41.000Z",
  "delivered_at": "2026-10-25T10:14:04.120Z"
}

order.review

Sent when a payment arrived but did not match the order exactly (for example a different amount or currency), so the order is waiting for you to approve or reject it in the dashboard. The body has the same fields as order.paid; status tells you why (for example manual_review). Do not deliver goods on this event — wait for order.paid.

order.expired

Sent when an order's payment window closes before it is paid. Same fields as order.paid, with status: "expired". A late payment can still arrive afterwards and produce order.paid.

order.refunded

Sent when you refund an order (from the dashboard or the refunds API) and Stripe accepts it.

order.refunded body
{
  "event": "order.refunded",
  "order_ref": "ORD-9F2C61D04B7A3E58",
  "refund_id": 31,
  "amount": 10,
  "currency": "EUR",
  "status": "succeeded",
  "reason": "Partial refund",
  "total_refunded": 10,
  "fully_refunded": false,
  "created_at": "2026-10-25T11:02:41.000Z",
  "delivered_at": "2026-10-25T11:02:42.300Z"
}

invoice.paid

Sent when one of your invoices is paid through its payment link.

invoice.paid body
{
  "event": "invoice.paid",
  "invoice_number": "INV-0004",
  "amount": 99.75,
  "currency": "USDT",
  "customer_name": "Global Tech Ltd",
  "customer_email": "[email protected]",
  "order_ref": "ORD-9F2C61D04B7A3E58",
  "paid_at": "2026-10-25T10:14:03.000Z",
  "delivered_at": "2026-10-25T10:14:04.120Z"
}

test.ping

Sent when you click Send test next to an endpoint in Dashboard → Webhooks. It is signed like every other event, so you can check your signature verification. Reply with any 2xx.

transaction.unclaimed

Sent when a bank alert reaches PayerNex (an SMS forwarded by the Android app, or a forwarded bank email) and doesn't match any pending order. It is useful for manual reconciliation. The fields come from parsing the alert, so any of them can be null.

{
  "event": "transaction.unclaimed",
  "gateway_id": 12,
  "gateway_name": "Meezan Bank",
  "gateway_type": "bank",
  "sms_log_id": 8812,
  "amount": 7000,
  "sender_name": "MUHAMMAD ALI",
  "sender_account": "0123456789",
  "bank_tx_id": "FT2629810452",
  "received_at": "2026-10-25T10:09:55.000Z",
  "raw_sms": "PKR 7,000.00 received from MUHAMMAD ALI …",
  "delivered_at": "2026-10-25T10:09:56.310Z"
}

payment.disputed

Sent when a buyer disputes a card payment with their bank (Stripe charge.dispute.created) and again when the dispute closes (charge.dispute.closed, with the final status won or lost). It goes to your order IPN URL, signed exactly like payment.completed (X-Signature, with X-Webhook-Event: payment.disputed), and to webhook endpoints that subscribe to it. Respond with evidence in your Stripe dashboard before evidence_due_by.

payment.disputed body
{
  "event": "payment.disputed",
  "order_ref": "ORD-9F2C61D04B7A3E58",
  "transaction_id": "ORD-9F2C61D04B7A3E58",
  "amount": 25,
  "currency": "USD",
  "reason": "fraudulent",
  "status": "needs_response",
  "evidence_due_by": "2026-12-06T23:59:59.000Z"
}

To receive disputes, your Stripe webhook endpoint (the URL shown on the Stripe gateway in PayerNex) must include the charge.dispute.created and charge.dispute.closed events. A payment.disputed webhook is not retried; the order's dispute field always has the latest state.

No webhook of any kind is sent when an order is created, cancelled, expires, goes to manual_review, is rejected, or fails (a card refused by strict 3D Secure is refunded and its order set to failed). If a manual_review order is later approved, PayerNex sends the normal payment.completed / order.paid notifications at that point.

Delivery & retries #

RuleBehaviour
MethodPOST with a JSON body.
Timeout15 seconds. Reply quickly and do slow work after you respond.
SuccessAny 2xx status. The response body is ignored.
RedirectsNot followed. A 301/302 counts as a failure, so use your final https:// URL.
RetriesOrder notifications (payment.completed to your ipn_url / callback URL) that fail are resent up to 5 more times, about 1 min, 5 min, 30 min, 2 h and 12 h after the previous attempt, until one returns 2xx. Webhook endpoint events (order.paid, transaction.unclaimed) are sent once.
LogEvery attempt, with its HTTP status, appears in Dashboard → Webhooks → Recent Deliveries. Status 0 means the connection failed or the URL was blocked.

Plan for missed webhooks. If your server stays down past the last retry, the notification is not sent again. Run a periodic job that calls GET /api/v1/order/{order_ref} for your unpaid invoices, for example every few minutes until expires_at and once more shortly after. Fulfil any that come back paid.

URL requirements #

Before each delivery PayerNex checks the URL. If the check fails, it records the delivery as blocked (status 0) and sends nothing:

  • The scheme must be http:// or https://. Use HTTPS.
  • The port must be the default, or one of 80, 443, 8080, 8443.
  • The host must not be localhost or end in .local, .internal or .localhost.
  • Every IP the hostname resolves to must be public. Private (10/8, 172.16/12, 192.168/16), loopback, link-local, CGNAT (100.64/10) and IPv6 ULA/link-local addresses are rejected.
  • URL fields hold at most 500 characters.

To test locally, expose your machine with a public tunnel (any HTTPS tunnelling service) and use that URL as ipn_url.

Checklist #

  • Check the signature against the raw body with the right secret and header, and reject a mismatch with 401.
  • Find your invoice by order_ref, not by customer_id or description alone.
  • Make sure GET /api/v1/order/{order_ref} returns status: "paid", and compare paid_amount/paid_currency with what you expected.
  • Process each order_ref only once and return 200 for repeats.
  • Reply within 15 seconds with a 2xx.
  • Reconcile unpaid invoices with the API in case every retry fails.