Skip to content
Meem Payment

Accept payments

Payments API

A single contract for the whole payment lifecycle. You call Meem; your published routing workflow picks the gateway account, and the response has the same shape whichever PSP processed it.

Operations

OperationEndpointPermissionSuccess status
AuthorizePOST /api/v1/paymentspayments.authorizeAuthorized
Purchase (authorize + capture)POST /api/v1/payments + capture: truepayments.authorizeCaptured
Capture (full or partial)POST /api/v1/payments/{id}/capturepayments.captureCaptured · PartiallyCaptured
VoidPOST /api/v1/payments/{id}/voidpayments.voidVoided
Refund (full or partial)POST /api/v1/payments/{id}/refundpayments.refundRefunded · PartiallyRefunded
RetrieveGET /api/v1/payments/{id}payments.read—
Timeline · routing trace · API callsGET /api/v1/payments/{id}/timeline · /routing-trace · /api-callspayments.read—
SearchGET /api/v1/paymentspayments.read—

Mutating calls (authorize, capture, void, refund) accept Idempotency-Key and X-Correlation-Id headers and return the same PaymentResponse body. Gateway support is checked per operation: if the selected account's gateway can't perform it, the call fails closed with 422 OPERATION_NOT_SUPPORTED.

Authorize a payment

POST/api/v1/payments
Bearer tokenPermission: payments.authorize
curl -X POST "https://api.sandbox.meem-dev.example/api/v1/payments" \
  -H "Authorization: Bearer $MEEM_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "X-Correlation-Id: $(uuidgen)" \
  -d '{
    "amount": 150,
    "currency": "SAR",
    "cardToken": "4000001111112223",
    "cvv": "123",
    "customerCountry": "SA",
    "metadata": {
      "orderRef": "ORDER-1001"
    }
  }'

Request body

amountnumberrequired
Amount in major units, greater than zero (e.g. 150.00).
currencystringrequired
Three-letter ISO 4217 code, e.g. SAR.
cardTokenstringrequired
A platform card token, never a raw card number in production. A hosted-fields token (tok_hf_…) is single-use, bound to your merchant and valid for 15 minutes. In the sandbox the mock gateways read the first six digits, so test card numbers work here.
cvvstringoptional
Used in-request only; never stored or logged.
capturebooleanoptional
true authorizes and captures in one call (purchase). Default false.
environmentstringoptional
Sandbox or Production. When omitted, it's resolved from your single resolvable gateway account; if that's ambiguous you get 422 payment.environment_indeterminate. Any other value is 422.
workflowIdstringoptional
Run a specific published workflow (id or code). Invalid, unpublished or foreign workflows return 422; they're never substituted. See Workflow selection.
channelstringoptional
web, mobile, link, api or recovery. Defaults to api; unknown values return 422.
paymentMethodstringoptional
Method code, e.g. card or mada.
cardSchemestringoptional
Scheme for routing and eligibility, e.g. mada, Visa. Falls back to cardBrand. A mada payment only routes to a mada-enabled account.
cardBrand · bin · cardIssuerstringoptional
Card attributes used by routing conditions.
country · customerCountry · ipCountrystringoptional
Country attributes used by routing and risk rules.
transactionType · deviceTypestringoptional
Further routing attributes.
customerIdentifierstringoptional
A stable customer id used by risk rules and velocity checks.
metadatamap<string, string>optional
Non-sensitive key-value pairs that routing conditions can match. Never put card data here.

Response (from the API contract)

{
  "paymentId": "6f1c2a9e-4b7d-4c1e-9a53-0d2b8f7e1c44",
  "status": "Authorized",
  "code": null,
  "normalizedCode": null,
  "declineCategory": null,
  "message": null,
  "redirectUrl": null,
  "correlationId": "0b8e5f8a-2f4c-4d6e-8a1b-3c9d7e6f5a21"
}
paymentIdstring (uuid)optional
The payment id, when a payment was created.
statusstringoptional
Lifecycle status after the call. See Status lifecycle.
codestringoptional
Machine-readable result code (decline code, RISK_BLOCKED, …). null on plain success.
normalizedCodestringoptional
Provider-independent decline code, e.g. DO_NOT_HONOUR.
declineCategorystringoptional
SoftDecline or HardDecline when declined.
messagestringoptional
Human-readable description. Don't parse it.
redirectUrlstringoptional
Where to send the customer for 3-D Secure or another required action.
correlationIdstringoptional
The correlation id for this flow, also echoed in the X-Correlation-Id response header and in webhooks.

Purchase: authorize and capture

Add "capture": true to capture the full amount in the same call. The payment lands directly in Captured and GET /payments/{id} reports requestedOperation: "Purchase". If the selected gateway can't capture, the call fails with 422 OPERATION_NOT_SUPPORTED; it never silently falls back to authorize-only.

curl -X POST "https://api.sandbox.meem-dev.example/api/v1/payments" \
  -H "Authorization: Bearer $MEEM_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "amount": 150,
    "currency": "SAR",
    "cardToken": "4000001111112223",
    "cvv": "123",
    "capture": true,
    "metadata": {
      "orderRef": "ORDER-1002"
    }
  }'

Capture

POST/api/v1/payments/{id}/capture
Bearer tokenPermission: payments.capture
amountnumberrequired
Greater than zero. Less than the authorized amount is a partial capture.
currencystringrequired
ISO 4217, same as the payment.
paymentId="<payment_id>"

curl -X POST "https://api.sandbox.meem-dev.example/api/v1/payments/$paymentId/capture" \
  -H "Authorization: Bearer $MEEM_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "amount": 100,
    "currency": "SAR"
  }'
  • Capturing more than was authorized returns 422 (AMOUNT_LIMIT_EXCEEDED).
  • Capturing a payment that isn't capturable (e.g. declined, voided) returns 409.

Void

POST/api/v1/payments/{id}/void
Bearer tokenPermission: payments.void

Releases an authorization before capture. The request has no body; send the Idempotency-Key header. Voiding a payment that isn't Authorized returns 409; a gateway without void support returns 422.

paymentId="<payment_id>"

curl -X POST "https://api.sandbox.meem-dev.example/api/v1/payments/$paymentId/void" \
  -H "Authorization: Bearer $MEEM_ACCESS_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)"

Refund

POST/api/v1/payments/{id}/refund
Bearer tokenPermission: payments.refund

Refund a captured payment in full or in part; partial refunds can repeat until the captured total is reached. amount and currency are required. More than the captured amount returns 422; a payment that isn't refundable returns 409.

paymentId="<payment_id>"

curl -X POST "https://api.sandbox.meem-dev.example/api/v1/payments/$paymentId/refund" \
  -H "Authorization: Bearer $MEEM_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "amount": 25,
    "currency": "SAR"
  }'

Retrieve and inspect

GET/api/v1/payments/{id}
Bearer tokenPermission: payments.read
paymentId="<payment_id>"

curl -X GET "https://api.sandbox.meem-dev.example/api/v1/payments/$paymentId" \
  -H "Authorization: Bearer $MEEM_ACCESS_TOKEN"
{
  "paymentId": "6f1c2a9e-4b7d-4c1e-9a53-0d2b8f7e1c44",
  "merchantId": "<merchant_id>",
  "status": "PartiallyRefunded",
  "amount": 150,
  "currency": "SAR",
  "capturedAmount": 100,
  "refundedAmount": 25,
  "createdAt": "2026-12-03T09:15:02+00:00",
  "updatedAt": "2026-12-03T09:21:40+00:00",
  "requestedOperation": "Authorize",
  "paymentMethod": "card",
  "workflowId": "<workflow_id>",
  "workflowVersion": 3,
  "workflowResolution": "Default",
  "channel": "api",
  "attempts": [
    {
      "attemptNumber": 1,
      "gatewayName": "Mock",
      "gatewayTransactionReference": "<gateway_reference>",
      "requestedAt": "2026-12-03T09:15:02+00:00",
      "respondedAt": "2026-12-03T09:15:02+00:00",
      "status": "Succeeded",
      "normalizedOutcome": "Success",
      "nextAction": "Complete",
      "durationMs": 41
    }
  ]
}

workflowResolution explains why the workflow was chosen (Explicit, SubAccountTrigger, MerchantTrigger, PaymentMethodMapping, Default or an inherited variant). Each attempt records the provider's raw code, the normalized outcome and code, and the nextAction the engine took.

Timeline, routing trace and API calls

EndpointReturns
GET /api/v1/payments/{id}/timelineOrdered events (created, channel, workflow, routing, attempt, decision, state, summary) with durations, attempt count and gateway time.
GET /api/v1/payments/{id}/routing-traceThe recorded routing decision: workflow and version, environment, selected gateway and account, evaluated rules, excluded accounts with reasons, and the fallback chain.
GET /api/v1/payments/{id}/api-callsCaptured API, gateway, status-query and webhook calls with redacted payloads: card numbers masked to first 6 / last 4, CVV removed, secrets replaced.
curl -X GET "https://api.sandbox.meem-dev.example/api/v1/payments?state=Captured&currency=SAR&from=2026-12-01T00:00:00Z&page=1&pageSize=25" \
  -H "Authorization: Bearer $MEEM_ACCESS_TOKEN"

Filters: state, currency, from, to (ISO 8601), page (default 1) and pageSize (default 25).

Status lifecycle

StatusMeaningWebhook
PendingAccepted, awaiting a final outcome.payment.pending
Requires3DSThe customer must complete 3-D Secure at redirectUrl.payment.requires_3ds
RequiresActionAnother customer action is required.payment.requires_action
AuthorizedFunds reserved; ready to capture or void.payment.authorized
PartiallyCaptured · CapturedPart or all of the authorized amount captured.payment.partially_captured · payment.captured
PartiallyRefunded · RefundedPart or all of the captured amount refunded.payment.partially_refunded · payment.refunded
VoidedAuthorization released before capture.payment.voided
DeclinedBusiness decline by the issuer or PSP. Final.payment.declined
FailedRisk block (402 RISK_BLOCKED), routing or technical failure with no remaining fallback, a rejected workflowId, or failed 3-D Secure.payment.failed
Expired · CancelledAuthorization expired, or the payment was cancelled.payment.expired · payment.cancelled
UnknownThe provider's outcome is ambiguous. Meem queries the provider; if still unknown the payment is held for reconciliation and never failed over.none

Internal states (Created, Routing, Processing, RefundPending) can appear on a payment but don't emit webhooks.

HTTP status mapping

HTTPWhen
200Authorized, Requires3DS, RequiresAction, Pending, Captured, PartiallyCaptured, Voided, Refunded, PartiallyRefunded.
402Business decline or risk block (RISK_BLOCKED). The body is a normal PaymentResponse.
422Validation error, unsupported operation, amount limit, unresolvable environment, no gateway or workflow configured, rejected workflowId, reused idempotency key.
409Same idempotency key still in flight, operation invalid for the current status, or the follow-up gateway account can't be resolved.
404Unknown payment, or a payment of another merchant.
401 · 403Missing or expired token · missing permission.
502Routing or technical failure with no fallback left (Failed).
{
  "paymentId": "a2d4f6b8-1c3e-4a5b-8d7f-9e0a1b2c3d4e",
  "status": "Declined",
  "code": "INSUFFICIENT_FUNDS",
  "normalizedCode": "INSUFFICIENT_FUNDS",
  "declineCategory": "SoftDecline",
  "message": "<human-readable reason>",
  "redirectUrl": null,
  "correlationId": "5d1e2f3a-4b5c-4d6e-8f9a-0b1c2d3e4f5a"
}

The full list of result codes is on Errors and status codes.

Declines and normalized codes

Each provider response is classified into one normalized outcome: Success, SoftDecline, HardDecline, TechnicalFailure, CustomerActionRequired, Pending or Unknown. Business declines are mapped to a provider-independent code. Unmapped declines are treated as hard declines: no retry and no failover.

Normalized codeCategoryFailover eligible
DO_NOT_HONOUR · BANK_DECLINE · INVALID_TRANSACTION · ISSUER_UNAVAILABLESoftDeclineYes, if the workflow allows it
INSUFFICIENT_FUNDS · LIMIT_EXCEEDEDSoftDeclineNo (retry later only)
EXPIRED_CARD · INVALID_CARD · INVALID_CVV · NOT_PERMITTED · RESTRICTED_CARDHardDeclineNo
LOST_CARD · STOLEN_CARD · PICK_UP_CARD · SUSPECTED_FRAUDHardDeclineNo
AUTHENTICATION_FAILEDHardDecline or SoftDecline, by providerNo (failover never bypasses authentication)
PROVIDER_ERRORTechnicalFailureYes
OUTCOME_UNKNOWNUnknownOnly after the provider confirms no charge

The live mapping table (provider, raw code, normalized code, retry and failover flags) is served at GET /api/v1/decline-mappings in the console API.

3-D Secure and customer actions

When a gateway needs the customer, the response is 200 with status Requires3DS or RequiresAction and a redirectUrl. Send the customer there. The final outcome arrives as a webhook (payment.authorized, payment.failed, …) and through GET /payments/{id}. A failed authentication ends in Failed with 3DS_AUTHENTICATION_FAILED.

{
  "paymentId": "<payment_id>",
  "status": "Requires3DS",
  "code": null,
  "message": null,
  "redirectUrl": "<challenge_url>",
  "correlationId": "<correlation_id>"
}

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.