Developers

API documentation

Merchant REST API for LIVE crypto payments — create invoices, redirect to hosted checkout, verify IPN webhooks, and settle to your wallet. Copy-paste examples in curl, Node, PHP, and Python.

Overview

MZA Payments is a crypto payment API for merchants. Create invoices, accept deposits in many cryptocurrencies, and settle to one payout wallet (for example USDT BEP-20) after confirmation.

This reference mirrors a Postman-style collection: every endpoint lists method, path, parameters, example requests, and example responses.

ItemValue
Base URLhttps://mzapayments.com/api/v1
ProtocolHTTPS + JSON
AuthAuthorization: Bearer <API_SECRET>
EnvironmentLIVE (mza_…) or SANDBOX (mza_test_…) — create keys in Dashboard → API keys
IdempotencyIdempotency-Key header on POST /invoices
Checkout URLhttps://mzapayments.com/pay/{code} (code = MZA-##########)
OpenAPIhttps://mzapayments.com/openapi.json
IPN secretDashboard → Webhooks / IPN (Show / Copy / Regenerate). This secret signs every delivery.

How MZA Payments works

Hosted checkout + invoice-first API. IPN uses sorted-JSON HMAC-SHA512 plus timestamped signatures.

TopicMZA Payments
SandboxSANDBOX API keys (mza_test_…). Create invoice → POST /sandbox/simulate-payment to fake-confirm and fire IPNs.
Deposit addressCreate an invoice and send the buyer to hosted checkout. A payment and deposit address exist only when cryptoCurrency is set on the invoice, or the buyer picks a coin on checkout.
IPN callbackAccount webhooks (Dashboard → Webhooks / POST /webhooks) plus optional per-invoice ipnCallbackUrl on POST /invoices (same HMAC headers). IPN secret alone is not enough (see GET /account).
Balance / min-amount / payout statusGET /balance (custody), GET /min-amount?fromCurrency=&toCurrency=, GET /payouts/:id, POST /payments/:id/refund ({ refundAddress } + X-MZA-TOTP → custody payout + payment.refunded IPN).
success_url / cancel_urlOptional successUrl / cancelUrl on POST /invoices (https). Tokens: {INVOICE_CODE}, {MERCHANT_ORDER_ID}, {STATUS}. Hosted checkout redirects after PAID / CANCELLED / EXPIRED.
Payout APIPOST /api/v1/payouts (LIVE key + payouts:write). Requires body idempotencyKey (bound to amount/destination), destination on Dashboard payout wallets, X-MZA-TOTP (2FA), and optional MZA_PAYOUT_IP_ALLOWLIST. Bare usdt/usdc require network.

Authentication

Create a LIVE API key in Dashboard → API keys. Format: `mza_<8-char-prefix>_<secret>`. New keys include invoices, payments, and webhooks permissions by default.

Authenticate with Authorization: Bearer <full_secret>. Never put secrets in browsers, mobile apps, or public repos — call /api/v1 from your backend only.

Permissions: invoices:read|write, payments:read|write, webhooks:read|write, payouts:read|write.

Rate limits: 120 requests/minute per API key and 60 auth attempts/minute per IP. Responses include X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset (unix seconds). Exceeding returns HTTP 429 with Retry-After.

SANDBOX: create a key with environment SANDBOX (secret starts with mza_test_). Then POST /sandbox/simulate-payment with paymentId or invoiceId.

Request headers
Authorization: Bearer mza_a1b2c3d4_yourFullSecretHere
Content-Type: application/json
Idempotency-Key: order-123-retry-1   # optional, POST /invoices

Responses & errors

Successful responses: `{ ok: true, requestId, data }`. Errors: `{ ok: false, requestId, error: { code, message, details? } }` — same pattern as professional gateways (stable codes, no stack traces).

Always log `requestId` (also returned as X-Request-Id) when contacting support.

details is only present on VALIDATION_ERROR (field-level Zod flatten). 500 INTERNAL_ERROR never includes internal exception text.

HTTPerror.codeMeaning
400BAD_REQUESTMalformed JSON or unsupported operation
400PAYOUT_WALLET_REQUIREDNo active payout wallet / auto-convert — see docsUrl
400AMOUNT_TOO_SMALLBelow minimum for the selected coin
400COIN_PAUSEDCoin unavailable for this invoice
400RATE_LOCKED_EXPIREDDeposit rate lock expired — reselect coin
401UNAUTHORIZEDMissing / invalid API key or wrong key format
403FORBIDDENKey lacks required permission
404NOT_FOUNDResource not found for this merchant
409CONFLICTReused Idempotency-Key with a different body, slug clash, or invalid state transition
422VALIDATION_ERRORSchema validation failed (see details)
429RATE_LIMITEDToo many requests — Retry-After: 60
500INTERNAL_ERRORUnexpected server error (safe message only)
Error examples
// 422 validation
{
  "ok": false,
  "requestId": "req_a1b2c3d4e5f6",
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Validation failed",
    "details": { "fieldErrors": { "amountDue": ["Required"] } }
  }
}

// 401 unauthorized
{ "ok": false, "requestId": "req_…", "error": { "code": "UNAUTHORIZED", "message": "Invalid API key" } }

// 403 forbidden
{ "ok": false, "requestId": "req_…", "error": { "code": "FORBIDDEN", "message": "Missing permission: invoices:write" } }

// 429 rate limited
{ "ok": false, "requestId": "req_…", "error": { "code": "RATE_LIMITED", "message": "API rate limit exceeded (120 requests/minute). Retry after 60 seconds." } }

// 500 internal (no stack / DB details)
{ "ok": false, "requestId": "req_…", "error": { "code": "INTERNAL_ERROR", "message": "Failed to create invoice" } }

// 400 payout wallet (stable business code + docsUrl)
{
  "ok": false,
  "requestId": "req_…",
  "error": {
    "code": "PAYOUT_WALLET_REQUIRED",
    "message": "Configure a payout wallet before creating live invoices",
    "docsUrl": "https://mzapayments.com/docs#error-payout-wallet-required"
  }
}

Error: PAYOUT_WALLET_REQUIRED

LIVE invoices and deposits require at least one active payout wallet with auto-convert (Dashboard → Payout wallets), e.g. USDT BEP-20.

Fix: add a wallet, then retry POST /invoices.

Error: AMOUNT_TOO_SMALL

The fiat or crypto amount is below the network / exchange minimum for the selected coin. Raise amountDue or pick another coin.

Error: COIN_PAUSED

That deposit coin is temporarily unavailable for this merchant or settlement route. Offer another coin at checkout.

Error: RATE_LOCKED_EXPIRED

The ~20 minute deposit rate lock expired. Reselect the coin on hosted checkout to create a fresh payment.

Account & settlements

GET /account — payoutWalletReady, webhookConfigured, feePercent, environment.

GET /settlements and GET /settlements/{id} — settle amounts, fee, rate, txHash, merchantOrderId.

GET /webhooks/deliveries and POST /webhooks/deliveries/{id}/retry — IPN attempt history (HMAC verification unchanged).

Payment statuses

Poll GET /payments/{id} or rely on webhooks. Treat CONFIRMED (and OVERPAID when you accept overpay) as success only after you verify the webhook signature or re-fetch the payment.

StatusMeaningMerchant action
PENDINGAwaiting on-chain depositShow address + amount; wait
AWAITING_CONFIRMATIONSTx seen, confirmations in progressShow progress; do not fulfill yet
CONFIRMEDRequired confirmations reachedFulfill order / credit account
UNDERPAIDReceived less than expectedApply your underpay policy
OVERPAIDReceived more than expectedFulfill; optional credit
EXPIREDPayment window endedCreate a new invoice/payment
FAILEDPayment failedRetry or contact customer
REFUNDEDFunds returnedUpdate order state

Quick start

1. Dashboard → Payout wallets: set your settlement wallet (e.g. USDT BEP-20).

2. Dashboard → API keys: create a LIVE key and copy the secret once (Show/Copy anytime after regenerate).

3. Dashboard → Webhooks / IPN: copy your IPN secret and register an HTTPS callback URL.

4. POST /invoices from your backend. Use data.invoice.checkoutUrl (or /pay/{code}) to redirect the buyer.

5. Buyer pays any supported coin on hosted checkout. After confirmations, we convert to your payout asset.

6. Fulfill only after verifying IPN for payment.confirmed or invoice.paid (or re-fetch GET /payments/{id}|{code}).

Sandbox: use an mza_test_ API key and POST /api/v1/sandbox/simulate-payment. LIVE keys (mza_…) create real on-chain invoices. Hosted payment links are LIVE-only.

Quick start (cURL)
# 1) Create invoice
curl -sS -X POST 'https://mzapayments.com/api/v1/invoices' \
  -H 'Authorization: Bearer YOUR_SECRET' \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: order_1001' \
  -d '{
    "orderId": "order_1001",
    "amountDue": "49.99",
    "currency": "USD",
    "description": "Pro plan"
  }'

# Response includes checkoutUrl — redirect the buyer there:
# https://mzapayments.com/pay/MZA-##########

# 2) Poll status (cuid or MZA code)
curl -sS 'https://mzapayments.com/api/v1/invoices/MZA-1234567890' \
  -H 'Authorization: Bearer YOUR_SECRET'

Currencies

List supported fiat and cryptocurrencies.

GET/currencies

Get available currencies

Returns fiat codes and the full crypto catalog (id, symbol, network, decimals, confirmations).

Example request
curl -sS -X GET 'https://mzapayments.com/api/v1/currencies' \
  -H 'Authorization: Bearer YOUR_SECRET' \
  -H 'Content-Type: application/json'
Example response
{
  "ok": true,
  "requestId": "req_…",
  "data": {
    "fiat": ["USD", "EUR", "GBP", "NGN"],
    "crypto": [
      {
        "id": "bnb",
        "symbol": "BNB",
        "name": "BNB",
        "network": { "id": "bsc", "name": "BNB Smart Chain", "short": "BSC" },
        "decimals": 18,
        "defaultConfirmations": 15
      },
      {
        "id": "usdt_bep20",
        "symbol": "USDT",
        "name": "Tether USD",
        "network": { "id": "bsc", "name": "BNB Smart Chain", "short": "BSC" },
        "decimals": 18,
        "defaultConfirmations": 15
      }
    ]
  }
}
  • Use crypto.id values (e.g. bnb, usdt_bep20) in invoice and estimate requests — not bare tickers when networks differ.

Estimate

Convert a fiat amount to an expected crypto amount at live rates.

GET/estimate

Get estimated price

Estimates how much crypto the customer should send for a fiat price. Rates can move — prefer creating a payment for a locked amount.

NameInTypeRequiredDescription
amountquerystringyesFiat amount as a decimal string, e.g. "100"
currencyquerystringyesFiat currency, e.g. "USD"
cryptoCurrencyquerystringyesCrypto id from /currencies, e.g. "bnb"
Example request
curl -sS 'https://mzapayments.com/api/v1/estimate?amount=…&currency=…&cryptoCurrency=…' \
  -H 'Authorization: Bearer YOUR_SECRET'
Example response
{
  "ok": true,
  "requestId": "req_…",
  "data": {
    "estimate": {
      "amountFiat": "10",
      "currency": "USD",
      "cryptoCurrency": "bnb",
      "cryptoAmount": "0.01716667",
      "rateUsd": "600",
      "environment": "LIVE",
      "platformFeePercent": 1.5,
      "conversionBufferPercent": 1.5
    }
  }
}
  • rateUsd is the USD price of 1 coin. cryptoAmount is what the buyer sends.
  • A live quote includes the platform fee and conversion buffer in cryptoAmount.
  • If the live price call fails, the same fields are returned from a static USD table. environment stays LIVE. There is no sandbox host.

Exchange

Read-only quotes from MZA Exchange. These endpoints do not move funds and do not create a payment.

GET/exchange/quote

Quote a conversion

Quotes from → to for a crypto amount. Auth required. This is not the checkout estimate.

NameInTypeRequiredDescription
fromquerystringyesSource crypto id, e.g. ltc
toquerystringyesDestination crypto id, e.g. usdt_bep20
amountquerystringyesAmount of the source coin, decimal string
settleAddressquerystringnoOptional destination address for venues that need one
Example request
curl -sS 'https://mzapayments.com/api/v1/exchange/quote?from=…&to=…&amount=…&settleAddress=…' \
  -H 'Authorization: Bearer YOUR_SECRET'
Example response
{
  "ok": true,
  "requestId": "req_…",
  "data": {
    "exchange": "MZA Exchange",
    "independent": true,
    "quote": {
      "routeable": true,
      "fromCurrency": "ltc",
      "toCurrency": "usdt_bep20",
      "fromAmount": "0.1",
      "expectedOut": "8.12",
      "venue": "thorchain",
      "rate": "81.2",
      "expiresAt": "2026-10-29T12:05:00.000Z"
    }
  }
}
GET/exchange/status

Exchange status

Which conversion venues are enabled. Auth required.

Example request
curl -sS -X GET 'https://mzapayments.com/api/v1/exchange/status' \
  -H 'Authorization: Bearer YOUR_SECRET' \
  -H 'Content-Type: application/json'
Example response
{
  "ok": true,
  "requestId": "req_…",
  "data": {
    "exchange": {
      "name": "MZA Exchange",
      "independent": true,
      "venues": [],
      "recentErrors": [],
      "pairCoverageNote": "",
      "pausedPayoutCoins": [],
      "pausedDepositCoins": []
    }
  }
}

Invoices

Invoices are the primary way to collect payment. Optionally set cryptoCurrency; otherwise the customer chooses at hosted checkout.

POST/invoices

Create invoice

Creates an invoice. If cryptoCurrency is set and live rails are ready, a payment may be created immediately; otherwise the customer selects a coin on the checkout page.

NameInTypeRequiredDescription
Idempotency-KeyheaderstringnoReplays the first 201 for 24 hours. A different body with the same key returns 409.
orderIdbodystringyesYour order id. The response returns it as merchantOrderId. Response orderId is the public MZA- code.
amountDuebodystringyesDecimal string, e.g. "49.99"
currencybodystringyesFiat currency, e.g. "USD"
cryptoCurrencybodystringnoOptional crypto id; omit to let customer choose
descriptionbodystringnoShown on checkout
customerEmailbodystringnoCustomer email
metadatabodyobjectnoArbitrary JSON for your system
expiresAtbodystring (ISO date)noInvoice expiry
successUrlbodystringnohttps URL; buyer redirected after PAID. Tokens: {INVOICE_CODE}, {MERCHANT_ORDER_ID}, {STATUS}
cancelUrlbodystringnohttps URL; buyer redirected after CANCELLED or EXPIRED. Same tokens as successUrl.
Example request
curl -sS -X POST 'https://mzapayments.com/api/v1/invoices' \
  -H 'Authorization: Bearer YOUR_SECRET' \
  -H 'Content-Type: application/json' \
  -d '{ "orderId": "order_1001", "amountDue": "49.99", "currency": "USD", "description": "Pro plan", "customerEmail": "buyer@example.com", "successUrl": "https://shop.example/thanks?order={MERCHANT_ORDER_ID}&inv={INVOICE_CODE}&status={STATUS}", "cancelUrl": "https://shop.example/cancel?order={MERCHANT_ORDER_ID}", "metadata": { "plan": "pro" } }'
Example response
{
  "ok": true,
  "requestId": "req_…",
  "data": {
    "invoice": {
      "id": "cmvgq7up000014u8roih62yq8",
      "code": "MZA-4829103746",
      "orderId": "MZA-4829103746",
      "merchantOrderId": "order_1001",
      "status": "PENDING",
      "amountDue": "49.99",
      "amountPaid": "0",
      "currency": "USD",
      "cryptoCurrency": null,
      "description": "Pro plan",
      "customerEmail": "buyer@example.com",
      "metadata": { "plan": "pro" },
      "successUrl": "https://shop.example/thanks?order={MERCHANT_ORDER_ID}&inv={INVOICE_CODE}&status={STATUS}",
      "cancelUrl": "https://shop.example/cancel?order={MERCHANT_ORDER_ID}",
      "checkoutUrl": "https://mzapayments.com/pay/MZA-4829103746",
      "expiresAt": null,
      "paidAt": null,
      "createdAt": "2026-10-20T12:00:00.000Z",
      "updatedAt": "2026-10-20T12:00:00.000Z"
    },
    "payment": null
  }
}
JSON body
{
  "orderId": "order_1001",
  "amountDue": "49.99",
  "currency": "USD",
  "description": "Pro plan",
  "customerEmail": "buyer@example.com",
  "successUrl": "https://shop.example/thanks?order={MERCHANT_ORDER_ID}&inv={INVOICE_CODE}&status={STATUS}",
  "cancelUrl": "https://shop.example/cancel?order={MERCHANT_ORDER_ID}",
  "metadata": { "plan": "pro" }
}
  • HTTP 201. The body includes data.invoice.checkoutUrl. Generated clients must read the 201 response, not an empty 200.
  • Request orderId is yours. Response orderId is the public MZA- code. Response merchantOrderId is the request orderId.
  • On invoice.paid / payment.* / settlement.completed, data.merchantOrderId and data.invoiceCode (or code) are always present when an invoice is linked.
  • The same Idempotency-Key returns the first response with Idempotent-Replayed: true. A changed body with that key returns 409.
  • successUrl / cancelUrl (https only) redirect the buyer from hosted checkout after PAID or CANCELLED/EXPIRED. Tokens: {INVOICE_CODE}, {MERCHANT_ORDER_ID}, {STATUS}.
  • Redirect buyers to data.invoice.checkoutUrl (preferred).
  • GET /invoices/{id} accepts either the internal cuid or the public MZA-########## code. GET /invoices?merchantOrderId=… looks up by your order id.
  • Duplicate merchantOrderId / orderId returns the existing invoice (HTTP 200) with Idempotent-Replayed: true and data.replayed=true (not 409).
  • Missing payout wallet on LIVE returns error.code PAYOUT_WALLET_REQUIRED (with docsUrl).
  • Omit cryptoCurrency so the customer picks a coin at checkout. Set it only when you want a payment and deposit address in data.payment immediately.
GET/invoices

List invoices

Cursor-paginated invoice list for the authenticated merchant.

NameInTypeRequiredDescription
limitqueryintegerno1–100, default 25
cursorquerystringnoNext page cursor (invoice id)
statusquerystringnoDRAFT | PENDING | PARTIALLY_PAID | PAID | EXPIRED | CANCELLED
merchantOrderIdquerystringnoYour order id. When set, returns that invoice (also aliased as orderId).
Example request
curl -sS 'https://mzapayments.com/api/v1/invoices?limit=…&cursor=…&status=…&merchantOrderId=…' \
  -H 'Authorization: Bearer YOUR_SECRET'
Example response
{
  "ok": true,
  "requestId": "req_…",
  "data": {
    "items": [ { "id": "cm…", "orderId": "MZA-4829103746", "merchantOrderId": "order_1001", "status": "PENDING", "amountDue": "49.99", "currency": "USD" } ],
    "nextCursor": null
  }
}
GET/invoices/{id}

Get invoice status

Fetch a single invoice by internal id or public MZA code.

NameInTypeRequiredDescription
idpathstringyesInvoice cuid or MZA-########## code
Example request
curl -sS -X GET 'https://mzapayments.com/api/v1/invoices/ID' \
  -H 'Authorization: Bearer YOUR_SECRET' \
  -H 'Content-Type: application/json'
Example response
{
  "ok": true,
  "requestId": "req_…",
  "data": {
    "invoice": {
      "id": "cmvgq7up000014u8roih62yq8",
      "code": "MZA-4829103746",
      "orderId": "MZA-4829103746",
      "merchantOrderId": "order_1001",
      "status": "PAID",
      "amountDue": "49.99",
      "amountPaid": "49.99",
      "currency": "USD",
      "checkoutUrl": "https://mzapayments.com/pay/MZA-4829103746",
      "paidAt": "2026-10-20T12:05:00.000Z"
    }
  }
}
PATCH/invoices/{id}

Cancel invoice

Currently supports cancelling an unpaid invoice.

NameInTypeRequiredDescription
idpathstringyesInvoice id
statusbodystringyesMust be "CANCELLED"
Example request
curl -sS -X PATCH 'https://mzapayments.com/api/v1/invoices/ID' \
  -H 'Authorization: Bearer YOUR_SECRET' \
  -H 'Content-Type: application/json' \
  -d '{ "status": "CANCELLED" }'
Example response
{
  "ok": true,
  "requestId": "req_…",
  "data": { "invoice": { "id": "cm…", "status": "CANCELLED" } }
}
JSON body
{ "status": "CANCELLED" }

Payments

A payment represents an on-chain deposit attempt for an invoice (or payment link), including deposit address and confirmation progress.

GET/payments

Get the list of payments

Cursor-paginated payments for the API key environment.

NameInTypeRequiredDescription
limitqueryintegerno1–100, default 25
cursorquerystringnoNext page cursor (payment id)
statusquerystringnoPaymentStatus filter
Example request
curl -sS 'https://mzapayments.com/api/v1/payments?limit=…&cursor=…&status=…' \
  -H 'Authorization: Bearer YOUR_SECRET'
Example response
{
  "ok": true,
  "requestId": "req_…",
  "data": {
    "items": [
      {
        "id": "pay_…",
        "invoiceId": "cm…",
        "status": "PENDING",
        "amountExpected": "0.0166",
        "amountReceived": "0",
        "currency": "USD",
        "cryptoCurrency": "bnb",
        "network": "bsc",
        "depositAddress": "0x…",
        "confirmations": 0,
        "requiredConfirmations": 15,
        "expiresAt": "2026-10-20T12:20:00.000Z"
      }
    ],
    "nextCursor": null
  }
}
GET/payments/{id}

Get payment status

Returns deposit address, amounts, confirmations, tx hash, and status for a payment.

NameInTypeRequiredDescription
idpathstringyesPayment id
Example request
curl -sS -X GET 'https://mzapayments.com/api/v1/payments/ID' \
  -H 'Authorization: Bearer YOUR_SECRET' \
  -H 'Content-Type: application/json'
Example response
{
  "ok": true,
  "requestId": "req_…",
  "data": {
    "payment": {
      "id": "pay_…",
      "invoiceId": "cm…",
      "status": "CONFIRMED",
      "amountExpected": "0.0166",
      "amountReceived": "0.0166",
      "cryptoCurrency": "bnb",
      "network": "bsc",
      "depositAddress": "0x…",
      "confirmations": 15,
      "requiredConfirmations": 15,
      "txHash": "0xabc…",
      "confirmedAt": "2026-10-20T12:08:00.000Z"
    }
  }
}

Hosted checkout

Hosted checkout is public (no API key). Merchants usually redirect customers here after creating an invoice.

GET /api/checkout/{invoiceId} — invoice + payment snapshot for the UI.

GET /api/checkout/{invoiceId}/select-currency — list deposit coins when a payout wallet is configured.

POST /api/checkout/{invoiceId}/select-currency — body `{ "cryptoCurrency": "bnb" }` creates the live payment + deposit address.

Select currency (public)
curl -sS -X POST 'https://mzapayments.com/api/checkout/INVOICE_ID/select-currency' \
  -H 'Content-Type: application/json' \
  -d '{ "cryptoCurrency": "bnb" }'

Webhooks (IPN)

Register an HTTPS IPN URL and verify every delivery with your account IPN secret (HMAC). Sorted SHA-512 checks plus Stripe-style timestamp signatures.

Dashboard → Webhooks / IPN: copy your IPN secret and register an HTTPS callback.

Every delivery is a JSON envelope: { id, type, created, data }. Fulfill when type is payment.confirmed or invoice.paid (also subscribe to payment.updated / settlement.completed as needed).

Headers: X-Mza-Ipn-Signature (HMAC-SHA512 of recursively key-sorted JSON), X-Mza-Signature (HMAC-SHA256 of `{timestamp}.{rawBody}`), X-Mza-Timestamp, X-Mza-Event.

Respond with HTTP 2xx quickly. A failed delivery is tried 5 times immediately, then on a schedule, up to 10 attempts total. Dashboard → Test delivery sends a fake webhook, not a simulated payment.

Currently emitted events: payment.updated, payment.underpaid, payment.overpaid, payment.confirmed, payment.refunded, invoice.paid, settlement.completed. Fulfill on payment.confirmed / invoice.paid; use payment.underpaid for partials.

Sample IPN body (payment.confirmed)
{
  "id": "clxdelivery…",
  "type": "payment.confirmed",
  "created": "2026-10-25T10:00:00.000Z",
  "data": {
    "paymentId": "cmpay…",
    "invoiceId": "cminv…",
    "status": "CONFIRMED",
    "environment": "LIVE",
    "txHash": "0x…",
    "confirmations": 15,
    "amountReceived": "0.01660000",
    "cryptoCurrency": "bnb"
  }
}
POST/webhooks

Register webhook endpoint

Registers an HTTPS URL. Deliveries are signed with the account IPN secret from Dashboard → Webhooks / IPN. The response returns that same secret.

NameInTypeRequiredDescription
urlbodystringyesHTTPS callback URL
eventsbodystring[]yesEvent types to subscribe to
secretbodystringnoIgnored. Signatures use the account IPN secret, not a per-endpoint secret.
enabledbodybooleannoDefault true
Example request
curl -sS -X POST 'https://mzapayments.com/api/v1/webhooks' \
  -H 'Authorization: Bearer YOUR_SECRET' \
  -H 'Content-Type: application/json' \
  -d '{ "url": "https://merchant.example/webhooks/mza", "events": [ "payment.updated", "payment.confirmed", "invoice.paid", "settlement.completed" ] }'
Example response
{
  "ok": true,
  "requestId": "req_…",
  "data": {
    "endpoint": {
      "id": "wh_…",
      "url": "https://merchant.example/webhooks/mza",
      "environment": "LIVE",
      "events": ["payment.confirmed", "invoice.paid", "settlement.completed"],
      "enabled": true
    },
    "secret": "<account IPN secret>",
    "ipnSecret": "<account IPN secret>"
  }
}
JSON body
{
  "url": "https://merchant.example/webhooks/mza",
  "events": [
    "payment.updated",
    "payment.confirmed",
    "invoice.paid",
    "settlement.completed"
  ]
}
  • secret and ipnSecret are the same value: the account IPN secret.
  • Verify X-Mza-Ipn-Signature with that secret. A different secret from an older create-webhook response will reject real callbacks.
  • Copy it from Dashboard → Webhooks / IPN if you already saved it there.
GET/webhooks

List webhook endpoints

Lists endpoints for the API key environment (secret is never returned again).

Example request
curl -sS -X GET 'https://mzapayments.com/api/v1/webhooks' \
  -H 'Authorization: Bearer YOUR_SECRET' \
  -H 'Content-Type: application/json'
Example response
{
  "ok": true,
  "requestId": "req_…",
  "data": {
    "items": [
      {
        "id": "wh_…",
        "url": "https://merchant.example/webhooks/mza",
        "events": ["payment.confirmed", "invoice.paid"],
        "enabled": true
      }
    ]
  }
}
PATCH/webhooks

Update webhook endpoint

Update URL, events, or enabled. A secret in the body does not change how deliveries are signed.

Example request
curl -sS -X PATCH 'https://mzapayments.com/api/v1/webhooks' \
  -H 'Authorization: Bearer YOUR_SECRET' \
  -H 'Content-Type: application/json' \
  -d '{ "id": "wh_…", "enabled": true, "events": ["payment.updated", "payment.confirmed", "invoice.paid", "settlement.completed"] }'
Example response
{
  "ok": true,
  "requestId": "req_…",
  "data": { "endpoint": { "id": "wh_…", "enabled": true } }
}
JSON body
{
  "id": "wh_…",
  "enabled": true,
  "events": ["payment.updated", "payment.confirmed", "invoice.paid", "settlement.completed"]
}
Verify IPN — Node.js
const crypto = require("crypto");

function sortKeys(value) {
  if (Array.isArray(value)) return value.map(sortKeys);
  if (value && typeof value === "object") {
    return Object.keys(value).sort().reduce((o, k) => {
      o[k] = sortKeys(value[k]);
      return o;
    }, {});
  }
  return value;
}

function verifyIpn(bodyObj, signature, ipnSecret) {
  const expected = crypto
    .createHmac("sha512", ipnSecret)
    .update(JSON.stringify(sortKeys(bodyObj)))
    .digest("hex");
  try {
    return crypto.timingSafeEqual(
      Buffer.from(expected, "utf8"),
      Buffer.from(String(signature), "utf8"),
    );
  } catch {
    return false;
  }
}

// Stripe-style header: HMAC-SHA256 of "${timestamp}.${rawBody}"
function verifyTimestampSig(rawBody, timestamp, signature, ipnSecret) {
  const expected = crypto
    .createHmac("sha256", ipnSecret)
    .update(`${timestamp}.${rawBody}`)
    .digest("hex");
  try {
    return crypto.timingSafeEqual(
      Buffer.from(expected, "utf8"),
      Buffer.from(String(signature), "utf8"),
    );
  } catch {
    return false;
  }
}

app.post("/api/mza-ipn", express.raw({ type: "*/*" }), (req, res) => {
  const rawBody = Buffer.isBuffer(req.body)
    ? req.body.toString("utf8")
    : String(req.body ?? "");
  const body = JSON.parse(rawBody);
  const ipnSig = req.get("X-Mza-Ipn-Signature");
  const ts = req.get("X-Mza-Timestamp");
  const tsSig = req.get("X-Mza-Signature");
  const secret = process.env.MZA_IPN_SECRET;
  if (
    !ipnSig ||
    !verifyIpn(body, ipnSig, secret) ||
    !ts ||
    !tsSig ||
    !verifyTimestampSig(rawBody, ts, tsSig, secret)
  ) {
    return res.status(401).send("invalid IPN signature");
  }
  // Optional replay guard: reject if |now - X-Mza-Timestamp| > 5 minutes
  if (req.body.type === "invoice.paid") {
    // Fulfill data.merchantOrderId — the orderId you sent to POST /invoices.
    // data.orderId is the public MZA- code, same as the invoice response.
    fulfill(req.body.data.merchantOrderId);
  }
  // use req.body.id so a retried delivery is applied once
  res.status(200).send("OK");
});
Verify IPN — PHP
<?php
function mza_sort_keys($value) {
  if (!is_array($value)) return $value;
  $isList = array_keys($value) === range(0, count($value) - 1);
  if ($isList) return array_map('mza_sort_keys', $value);
  ksort($value);
  foreach ($value as $k => $v) $value[$k] = mza_sort_keys($v);
  return $value;
}

function mza_verify_ipn(array $body, string $signature, string $ipnSecret): bool {
  $sorted = mza_sort_keys($body);
  $expected = hash_hmac(
    'sha512',
    json_encode($sorted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),
    $ipnSecret
  );
  return hash_equals($expected, $signature);
}

$raw = file_get_contents('php://input');
$body = json_decode($raw, true);
$sig = $_SERVER['HTTP_X_MZA_IPN_SIGNATURE'] ?? '';
if (!$body || !mza_verify_ipn($body, $sig, getenv('MZA_IPN_SECRET'))) {
  http_response_code(401);
  exit('invalid IPN signature');
}
// invoice.paid: fulfill $body['data']['merchantOrderId'] (your order id).
// $body['data']['orderId'] is the public MZA- code, same as the invoice API.
http_response_code(200);
echo 'OK';
Verify IPN — Python
import hashlib, hmac, json, os
from flask import Flask, request

app = Flask(__name__)

def sort_keys(value):
    if isinstance(value, list):
        return [sort_keys(v) for v in value]
    if isinstance(value, dict):
        return {k: sort_keys(value[k]) for k in sorted(value)}
    return value

def verify_ipn(body: dict, signature: str, secret: str) -> bool:
    expected = hmac.new(
        secret.encode(),
        json.dumps(sort_keys(body), separators=(",", ":"), ensure_ascii=False).encode(),
        hashlib.sha512,
    ).hexdigest()
    return hmac.compare_digest(expected, signature or "")

@app.post("/api/mza-ipn")
def mza_ipn():
    body = request.get_json(force=True, silent=True) or {}
    sig = request.headers.get("X-Mza-Ipn-Signature", "")
    if not verify_ipn(body, sig, os.environ["MZA_IPN_SECRET"]):
        return ("invalid IPN signature", 401)
    if body.get("type") == "invoice.paid":
        # Fulfill body["data"]["merchantOrderId"] (your order id).
        # body["data"]["orderId"] is the public MZA- code.
        shop_order = (body.get("data") or {}).get("merchantOrderId")
    elif body.get("type") == "payment.confirmed":
        shop_order = None
    else:
        shop_order = None
    _ = shop_order  # idempotent on body["id"]
    return ("OK", 200)

Settlement

Merchants configure one active payout wallet (currency + address) with auto-convert in the dashboard.

Customers may pay with any supported coin. After the deposit is confirmed, value is converted to the payout currency and sent to the payout address.

Platform fee (default ~1.5%) is applied on settlement. Conversion buffer/spread from the live convert rail may also apply.

You will also receive settlement.completed when payout finishes. Settlement preference and history are in Dashboard → Payout wallets / Settlements.