Skip to content
Meem Payment

Build reliably

Webhooks

Meem POSTs a signed JSON event to your endpoint whenever a payment changes state. Verify the signature over the raw body, acknowledge fast, and process each event idempotently.

Register an endpoint

POST/api/v1/webhook-endpoints
Bearer tokenPermission: webhooks.manage
urlstringrequired
Absolute https URL of your receiver. Checked by the SSRF guard.
eventTypesarray<string>optional
Event types to receive. Empty or omitted means all events. Names aren't validated, so copy them exactly from the list below.
curl -X POST "https://api.sandbox.meem-dev.example/api/v1/webhook-endpoints" \
  -H "Authorization: Bearer $MEEM_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://shop.example.com/webhooks/meem",
    "eventTypes": [
      "payment.authorized",
      "payment.captured",
      "payment.declined",
      "payment.refunded"
    ]
  }'
{
  "endpoint": {
    "id": "848b7ec6-7087-42a8-ba17-bb980c397f74",
    "merchantId": "<merchant_id>",
    "url": "https://shop.example.com/webhooks/meem",
    "eventTypes": [
      "payment.authorized",
      "payment.captured",
      "payment.declined",
      "payment.refunded"
    ],
    "active": true,
    "createdAt": "2026-12-03T09:00:00+00:00"
  },
  "signingSecret": "whsec_<shown_once>"
}

Event types

One event per payment state transition. Internal states (Created, Routing, Processing, RefundPending, Unknown) don't produce events.

Event typePayment status
payment.authorizedAuthorized
payment.captured · payment.partially_capturedCaptured · PartiallyCaptured
payment.refunded · payment.partially_refundedRefunded · PartiallyRefunded
payment.voidedVoided
payment.declinedDeclined
payment.failedFailed
payment.pendingPending
payment.requires_3ds · payment.requires_actionRequires3DS · RequiresAction
payment.expired · payment.cancelledExpired · Cancelled

Request format

Each delivery is a POST with Content-Type: application/json, the signature in X-Webhook-Signature and the flow's X-Correlation-Id. The body is compact JSON with snake_case keys; null fields are omitted.

{
  "event_id": "11111111-1111-1111-1111-111111111111",
  "event_type": "payment.captured",
  "payment_id": "22222222-2222-2222-2222-222222222222",
  "merchant_id": "33333333-3333-3333-3333-333333333333",
  "previous_state": "Authorized",
  "new_state": "Captured",
  "occurred_at": "2026-12-03T09:20:00+00:00",
  "correlation_id": "0b8e5f8a-2f4c-4d6e-8a1b-3c9d7e6f5a21",
  "data": {
    "amount": "150.00",
    "currency": "SAR"
  }
}
event_idstring (uuid)required
Unique per event. Use it to de-duplicate.
event_typestringrequired
One of the event types.
payment_id · merchant_idstring (uuid)required
The payment and its merchant.
previous_state · new_statestringoptional
The transition that triggered the event.
occurred_atstring (date-time)required
When the transition happened.
correlation_idstringrequired
Ties the event to the originating API request and logs.
datamap<string, string>optional
Non-sensitive details such as amount and currency. Never card data.

Verify the signature

  • Signature = HMAC-SHA256, key = your signingSecret (the full whsec_… string, UTF-8), message = the raw request body bytes.
  • Output is lowercase hex, sent as-is in X-Webhook-Signature (no prefix, no timestamp).
  • Verify before parsing. Re-serialising JSON changes bytes and breaks the check.
  • Compare in constant time and reject mismatches with 401.
# BODY: the exact raw request body you received. SIGNATURE: the X-Webhook-Signature header.
EXPECTED=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$MEEM_WEBHOOK_SECRET" | sed 's/^.* //')

if [ "$EXPECTED" = "$SIGNATURE" ]; then echo "valid"; else echo "invalid"; fi

Process events idempotently

  1. Store event_id with a unique constraint; if it's already there, return 200 and stop.
  2. Apply state changes keyed by payment_id and new_state, so applying payment.captured twice has no extra effect.
  3. Don't assume ordering. When in doubt, read the current state with GET /api/v1/payments/{payment_id} and act on that.
  4. Acknowledge with 2xx quickly and do slow work asynchronously.

Delivery, retries and replay

  • A delivery succeeds only on a 2xx received within 10 seconds. A later 2xx counts as a failure.
  • Failures are retried with exponential backoff: up to 6 attempts in total, waiting about 1, 2, 4, 8 and 16 minutes between them.
  • After the last attempt the delivery is marked failed and appears in the failed-deliveries queue.
EndpointPermissionPurpose
GET /api/v1/webhook-deliveries/failedwebhooks.readFailed deliveries for your merchant.
POST /api/v1/webhook-deliveries/{id}/replaywebhooks.manageRe-queue a delivery; returns 202.
deliveryId="<delivery_id>"

curl -X POST "https://api.sandbox.meem-dev.example/api/v1/webhook-deliveries/$deliveryId/replay" \
  -H "Authorization: Bearer $MEEM_ACCESS_TOKEN"
{
  "deliveryId": "<delivery_id>",
  "status": "replay_scheduled"
}

Destination rules (SSRF guard)

Meem refuses to call internal networks on your behalf. The URL is checked when you register it and again before every delivery, because DNS can change.

  • Absolute http or https URL; use https for real endpoints.
  • Every address the host resolves to must be public. Private (10/8, 172.16/12, 192.168/16), link-local (169.254/16, including cloud metadata), carrier-grade NAT (100.64/10), loopback, reserved and IPv6 unique-local or link-local addresses are rejected.
  • Loopback is allowed only in non-production deployments, for local testing.
  • A blocked URL is rejected at registration with 422 (webhook_endpoint.invalid_destination); a URL that becomes blocked later fails its deliveries.

Documentation reflects the platform as verified on 3 December 2026. Placeholder hosts and credentials are used throughout; your real sandbox host and keys are provided at onboarding.