Webhooks: receiving and verifying events
RedPay tells your system about payment results with HTTP POST requests to your notification URL: the payment's
asyncAckUrl, or, without it, the notification URL set on your point of sale (VPos) in the merchant panel.
There are two notification formats, depending on the API the payment was created with:
| Payment created with | Format | Signature header |
|---|---|---|
Gate API (/api/payment_intent) |
Webhook events | RedPay-Signature (HMAC-SHA256 hex, VPos webhook secret, with timestamp) |
| Gate API v1, Plugin API | Legacy result notification | X-Signature-SHA256 (HMAC-SHA256 Base64, VPos Auth-Key) |
Both formats share the delivery rules:
- Answer any
2xxwithin 15 seconds (connection timeout 5 seconds). Process the event afterwards, e.g. in a queue. - Failed deliveries are retried after 1 min, 5 min, 15 min, 1 h, 3 h, 6 h, 12 h and 24 h (about two days).
- Redirects (
3xx) are not followed and count as a failure. Use the final URL. - Only public internet addresses on ports 80 and 443 are called; URLs with credentials are refused.
- The same notification can arrive more than once. Make your handler idempotent.
Gate API events
POST /webhooks/redpay HTTP/1.1
Content-Type: application/json
RedPay-Signature: t=1763543782,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
RedPay-Event-Id: evt_9f1c2b
RedPay-Event-Type: payment_intent.succeeded
{"id":"evt_9f1c2b","type":"payment_intent.succeeded","created":"2026-11-19T10:16:22.010+01:00",
"apiVersion":"2026-11-01","data":{"object":{"id":"RP-W3YWEWH38PZTQW-TR","status":"SUCCESS", ...}}}
| Type | data.object |
|---|---|
payment_intent.succeeded, payment_intent.failed, payment_intent.canceled, payment_intent.expired |
PaymentIntent |
refund.succeeded, refund.failed |
Refund |
data.object is rendered in the API version the payment was created with (apiVersion).
Verification
- Read the raw body bytes before any JSON parsing.
- Split
RedPay-Signatureon,intot=...and one or morev1=.... - Compute
expected = hex(HMAC-SHA256(webhookSecret, t + "." + rawBody)). - Accept if
expectedequals anyv1(constant-time comparison) andtis at most 5 minutes old. - Deduplicate by event
id; retries and redeliveries reuse it.
During 24 hours after you rotate the webhook secret in the merchant panel, events carry two v1 values (old and new
secret), so you can switch your configuration without losing events.
Test vector: secret whsec_test, t=1700000000, body {"id":"evt_1"}: the signed string is
1700000000.{"id":"evt_1"}; compute its HMAC with your implementation and compare with a reference tool.
PHP
<?php
function redpayVerify(string $rawBody, string $header, string $secret, int $tolerance = 300): bool
{
$t = null; $signatures = [];
foreach (explode(',', $header) as $part) {
[$k, $v] = array_pad(explode('=', trim($part), 2), 2, '');
if ($k === 't') { $t = $v; } elseif ($k === 'v1') { $signatures[] = $v; }
}
if ($t === null || !ctype_digit($t) || abs(time() - (int)$t) > $tolerance) {
return false;
}
$expected = hash_hmac('sha256', $t . '.' . $rawBody, $secret);
foreach ($signatures as $sig) {
if (hash_equals($expected, $sig)) { return true; }
}
return false;
}
$raw = file_get_contents('php://input');
if (!redpayVerify($raw, $_SERVER['HTTP_REDPAY_SIGNATURE'] ?? '', getenv('REDPAY_WEBHOOK_SECRET'))) {
http_response_code(400);
exit;
}
$event = json_decode($raw, true);
// enqueue $event, deduplicate by $event['id']
http_response_code(200);
Node.js (Express)
const crypto = require('crypto');
const express = require('express');
const app = express();
function redpayVerify(rawBody, header, secret, toleranceSec = 300) {
const parts = header.split(',').map(p => p.trim().split('='));
const t = parts.find(([k]) => k === 't')?.[1];
const sigs = parts.filter(([k]) => k === 'v1').map(([, v]) => v);
if (!t || Math.abs(Date.now() / 1000 - Number(t)) > toleranceSec) return false;
const expected = crypto.createHmac('sha256', secret).update(`${t}.`).update(rawBody).digest('hex');
return sigs.some(s => s.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(s), Buffer.from(expected)));
}
app.post('/webhooks/redpay', express.raw({ type: 'application/json' }), (req, res) => {
if (!redpayVerify(req.body, req.get('RedPay-Signature') || '', process.env.REDPAY_WEBHOOK_SECRET)) {
return res.sendStatus(400);
}
const event = JSON.parse(req.body);
// enqueue event, deduplicate by event.id
res.sendStatus(200);
});
Java
boolean redpayVerify(byte[] rawBody, String header, String secret) throws Exception {
String t = null;
List<String> sigs = new ArrayList<>();
for (String part : header.split(",")) {
String[] kv = part.trim().split("=", 2);
if (kv.length == 2 && kv[0].equals("t")) t = kv[1];
if (kv.length == 2 && kv[0].equals("v1")) sigs.add(kv[1]);
}
if (t == null || Math.abs(Instant.now().getEpochSecond() - Long.parseLong(t)) > 300) return false;
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
mac.update((t + ".").getBytes(StandardCharsets.UTF_8));
byte[] expected = HexFormat.of().formatHex(mac.doFinal(rawBody)).getBytes(StandardCharsets.US_ASCII);
for (String sig : sigs) {
if (MessageDigest.isEqual(expected, sig.getBytes(StandardCharsets.US_ASCII))) return true;
}
return false;
}
Missed events
GET /api/payment_intent/{id}/events lists the events of a payment with their delivery state (attempts,
lastResponseCode, nextAttempt). POST /api/payment_intent/{id}/events/{eventId}/redeliver sends an event again
(at most 5 manual redeliveries per event).
Legacy result notification (Gate API v1, Plugin API)
POST /redpay/notify HTTP/1.1
Content-Type: application/json
X-Signature-SHA256: 0bH3Zq8n2t0aM4x5...base64...=
{"orderId":"100045","paymentIntentId":123456,"transactionId":"RP-W3YWEWH38PZTQW-TR",
"paymentStatus":"SUCCESS","paymentType":"BLIK","retry":false}
It is sent when the payment is paid (SUCCESS) or failed finally (FAILED). retry is true for repeated
deliveries. Verify X-Signature-SHA256 == Base64(HMAC-SHA256(Auth-Key, rawBody)) in constant time, then confirm the
status with GET /api/v1/payment_intent/{paymentId}/status (or the Plugin API status endpoint) before you change the
order.
<?php
$raw = file_get_contents('php://input');
$expected = base64_encode(hash_hmac('sha256', $raw, getenv('REDPAY_AUTH_KEY'), true));
if (!hash_equals($expected, $_SERVER['HTTP_X_SIGNATURE_SHA256'] ?? '')) {
http_response_code(400);
exit;
}