Every state change on a mini-app order or subscription is delivered as an outbound POST to a URL you register in the merchant portal. Payload is JSON, signed with an HMAC-SHA256 over the raw body using your webhook secret.
Retries: 8 attempts with exponential backoff over ~24 hours before the delivery drops to a dead-letter queue you can inspect in the portal.
Every webhook shares the same wrapper; the event-specific detail is in payload. Key your logic on event_type and dedupe on delivery_uuid (retries reuse it).
{
"event_type": "order.paid",
"delivery_uuid": "9b1e2f3a-…", // unique per delivery — dedupe on this
"mini_app_id": 64,
"vendor_id": 12,
"user_id": 6093, // null for mini-app lifecycle events
"payload": { /* event-specific — see below */ },
"delivered_at": "2026-11-09T12:00:00.000Z",
"attempt": 1 // 1..8; increments on retry
}Money fields are decimal strings. order.cancelled can arrive from two paths — the payment one (with amount/paid_at) on an auto-refund cancel, or the transition one (with reason).
{
"order_uuid": "0193b09d-…",
"order_number": "MA-2026-00042",
"mini_app_id": 64,
"vendor_id": 12,
"user_id": 6093,
"vendor_order_ref": "VND-CART-9b3f12",
"items": [ { "sku": "…", "name": "…", "qty": 2, "unit_price": 49.00 } ],
"total_amount": "124.20",
"currency": "SAR",
"status": "created",
"created_at": "2026-11-09T12:00:00.000Z"
}{
"order_uuid": "0193b09d-…",
"mini_app_id": 64,
"vendor_id": 12,
"user_id": 6093,
"vendor_order_ref": "VND-CART-9b3f12",
"status": "paid", // or "cancelled"
"from_state": "created",
"amount": "124.20",
"currency": "SAR",
"payment_method": "card", // card | wallet | apple_pay | tamara
"paid_at": "2026-11-09T12:00:00.000Z", // null unless paid
"cancelled_at": null // set when cancelled
}{
"order_uuid": "0193b09d-…",
"mini_app_id": 64,
"vendor_id": 12,
"user_id": 6093,
"vendor_order_ref": "VND-CART-9b3f12",
"status": "processing", // or "completed" / "cancelled"
"from_state": "paid",
"reason": null, // optional, e.g. a cancel reason
"updated_at": "2026-11-09T12:05:00.000Z"
}{
"order_uuid": "0193b09d-…",
"mini_app_id": 64,
"vendor_id": 12,
"user_id": 6093,
"vendor_order_ref": "VND-CART-9b3f12",
"refund_uuid": "7c2a…",
"amount": "124.20", // requested
"settled_amount": "124.20", // actually returned by the gateway
"fault": "vendor", // vendor | customer | platform | unknown
"reason": "Customer returned the item",
"refunded_at": "2026-11-09T12:30:00.000Z"
}{
"subscription_uuid": "0193c7f0-…",
"provider_subscription_ref": "SUB-GOLD-9b3f12",
"mini_app_id": 64,
"vendor_id": 12,
"user_id": 6093,
"status": "active", // the state after this event
"plan_code": "gold_monthly",
"amount": "29.00",
"currency": "SAR",
"interval": "month",
"interval_count": 1,
"from_status": "incomplete" // present on state-change events
}{
/* …common subscription fields… */
"status": "active",
"kind": "renewal", // activation | renewal | upgrade
"amount": "29.00",
"currency": "SAR",
"invoice_uuid": "0193c7f0-aa11-…" // match against change-plan's upgrade_invoice_uuid
}{
/* …common subscription fields… */
"status": "past_due",
"reason": "card_declined",
"attempt": 2, // 1-based dunning attempt
"next_retry_at": "2026-12-12T12:00:00.000Z", // omitted on the final attempt
"final": false, // true on the last attempt
"invoice_uuid": "0193c7f0-aa11-…"
}
// When every dunning attempt is exhausted, a subscription.cancelled follows:
{
/* …common subscription fields… */
"status": "cancelled",
"cause": "dunning_exhausted",
"attempts": 4
}{
"mini_app_id": 64,
"vendor_id": 12,
"user_id": null,
"reason": "Policy review", // null on restore
"suspended_at": "2026-11-09T12:00:00.000Z" // restored_at on mini_app.sg_restored
}// Every request carries X-MiniApp-Signature = sha256=<hex-hmac>
// Compare it against HMAC-SHA256(rawBody, webhookSecret).
const crypto = require('crypto');
function verify(rawBody, headerSig, secret) {
const expected = 'sha256=' + crypto
.createHmac('sha256', secret)
.update(rawBody)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(expected),
Buffer.from(headerSig)
);
}