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
| Operation | Endpoint | Permission | Success status |
|---|---|---|---|
| Authorize | POST /api/v1/payments | payments.authorize | Authorized |
| Purchase (authorize + capture) | POST /api/v1/payments + capture: true | payments.authorize | Captured |
| Capture (full or partial) | POST /api/v1/payments/{id}/capture | payments.capture | Captured · PartiallyCaptured |
| Void | POST /api/v1/payments/{id}/void | payments.void | Voided |
| Refund (full or partial) | POST /api/v1/payments/{id}/refund | payments.refund | Refunded · PartiallyRefunded |
| Retrieve | GET /api/v1/payments/{id} | payments.read | — |
| Timeline · routing trace · API calls | GET /api/v1/payments/{id}/timeline · /routing-trace · /api-calls | payments.read | — |
| Search | GET /api/v1/payments | payments.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
/api/v1/paymentspayments.authorizecurl -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.
capturebooleanoptionaltrueauthorizes and captures in one call (purchase). Defaultfalse.environmentstringoptionalSandboxorProduction. When omitted, it's resolved from your single resolvable gateway account; if that's ambiguous you get422 payment.environment_indeterminate. Any other value is422.workflowIdstringoptional- Run a specific published workflow (id or code). Invalid, unpublished or foreign workflows return
422; they're never substituted. See Workflow selection. channelstringoptionalweb,mobile,link,apiorrecovery. Defaults toapi; unknown values return422.paymentMethodstringoptional- Method code, e.g.
cardormada. cardSchemestringoptional- Scheme for routing and eligibility, e.g.
mada,Visa. Falls back tocardBrand. 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, …).nullon plain success. normalizedCodestringoptional- Provider-independent decline code, e.g.
DO_NOT_HONOUR. declineCategorystringoptionalSoftDeclineorHardDeclinewhen 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-Idresponse 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
/api/v1/payments/{id}/capturepayments.captureamountnumberrequired- 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
/api/v1/payments/{id}/voidpayments.voidReleases 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
/api/v1/payments/{id}/refundpayments.refundRefund 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
/api/v1/payments/{id}payments.readpaymentId="<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
| Endpoint | Returns |
|---|---|
GET /api/v1/payments/{id}/timeline | Ordered events (created, channel, workflow, routing, attempt, decision, state, summary) with durations, attempt count and gateway time. |
GET /api/v1/payments/{id}/routing-trace | The 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-calls | Captured API, gateway, status-query and webhook calls with redacted payloads: card numbers masked to first 6 / last 4, CVV removed, secrets replaced. |
Search
curl -X GET "https://api.sandbox.meem-dev.example/api/v1/payments?state=Captured¤cy=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
| Status | Meaning | Webhook |
|---|---|---|
Pending | Accepted, awaiting a final outcome. | payment.pending |
Requires3DS | The customer must complete 3-D Secure at redirectUrl. | payment.requires_3ds |
RequiresAction | Another customer action is required. | payment.requires_action |
Authorized | Funds reserved; ready to capture or void. | payment.authorized |
PartiallyCaptured · Captured | Part or all of the authorized amount captured. | payment.partially_captured · payment.captured |
PartiallyRefunded · Refunded | Part or all of the captured amount refunded. | payment.partially_refunded · payment.refunded |
Voided | Authorization released before capture. | payment.voided |
Declined | Business decline by the issuer or PSP. Final. | payment.declined |
Failed | Risk block (402 RISK_BLOCKED), routing or technical failure with no remaining fallback, a rejected workflowId, or failed 3-D Secure. | payment.failed |
Expired · Cancelled | Authorization expired, or the payment was cancelled. | payment.expired · payment.cancelled |
Unknown | The 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
| HTTP | When |
|---|---|
200 | Authorized, Requires3DS, RequiresAction, Pending, Captured, PartiallyCaptured, Voided, Refunded, PartiallyRefunded. |
402 | Business decline or risk block (RISK_BLOCKED). The body is a normal PaymentResponse. |
422 | Validation error, unsupported operation, amount limit, unresolvable environment, no gateway or workflow configured, rejected workflowId, reused idempotency key. |
409 | Same idempotency key still in flight, operation invalid for the current status, or the follow-up gateway account can't be resolved. |
404 | Unknown payment, or a payment of another merchant. |
401 · 403 | Missing or expired token · missing permission. |
502 | Routing 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 code | Category | Failover eligible |
|---|---|---|
DO_NOT_HONOUR · BANK_DECLINE · INVALID_TRANSACTION · ISSUER_UNAVAILABLE | SoftDecline | Yes, if the workflow allows it |
INSUFFICIENT_FUNDS · LIMIT_EXCEEDED | SoftDecline | No (retry later only) |
EXPIRED_CARD · INVALID_CARD · INVALID_CVV · NOT_PERMITTED · RESTRICTED_CARD | HardDecline | No |
LOST_CARD · STOLEN_CARD · PICK_UP_CARD · SUSPECTED_FRAUD | HardDecline | No |
AUTHENTICATION_FAILED | HardDecline or SoftDecline, by provider | No (failover never bypasses authentication) |
PROVIDER_ERROR | TechnicalFailure | Yes |
OUTCOME_UNKNOWN | Unknown | Only 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.