Scan Pay Open API Integration Guide

This guide is for partners that offer merchant QR payments to individual payers through the platform Open API. The API prefix is /open-api/v1/scan-pay. New transactions use the platform's crypto wallet balance (cw). Each payment request includes the payer's confirmation of the current quote. See the OpenAPI 3 specification for request and response schemas.

To get started, enable Scan Pay, obtain an access token, set up the individual payer entity and complete KYC, fund the wallet, and check capabilities. For each payment, decode the QR code, collect any required information, request a quote, obtain the payer's confirmation, submit the payment, and track the result through webhooks and payment lookups. Dynamic QR quotes calculate the price directly. A static QR quote creates a channel preparation order that the payment then reuses. The platform must verify and enable static QR support. Offer it only when GET /capabilities includes static in qrModes and returns staticQuoteMode=channel_prepare.

End-to-end flow

flowchart TD
  subgraph setup["Enable Scan Pay and prepare the payer"]
    Enable["Enable the scan_pay permission<br/>Confirm the funding mode and register the webhook"]
    Token["Obtain a token on the partner server<br/>POST /open-api/v1/auth/access_token"]
    Kyc["Set up the individual entity using existing permissions<br/>Check that the entity is active and kycStatus=completed"]
    FundingMode{"Funding mode for this API credential"}
    OwnerFunds["Fund the partner's primary crypto wallet<br/>Orders belong to the API primary account"]
    PayerFunds["Fund the payer's sub-account crypto wallet<br/>Orders belong to the payer sub-account"]
    Capabilities["Call GET /capabilities with a Bearer token<br/>Check that Scan Pay is available"]
    Enable --> Token --> Kyc --> FundingMode
    FundingMode -->|api_owner default| OwnerFunds --> Capabilities
    FundingMode -->|payer white label| PayerFunds --> Capabilities
  end

  subgraph payment["For each QR payment"]
    Decode["Send dgp-entity-id with POST /decodes"]
    Available["If several CW balances are eligible, use funding-sources to select one<br/>The platform can select a sole eligible balance"]
    Mode{"QR code type"}
    Dynamic["Use the decoded amount and collect required information<br/>POST /quotes returns price_only"]
    StaticEnabled{"Does the capability response enable static preparation?"}
    Static["Get the amount from the payer and collect required information<br/>POST /quotes creates a preparation order and returns channel_prepare"]
    Stop["Stop quoting or paying this static QR code"]
    Confirm["Show the merchant, fees, total debit, and quote expiry<br/>Get the payer's confirmation of the current quote"]
    Pay["Save the original payment callId, request, and confirmation<br/>POST /payments with the quoteId and confirmation"]
    Decode --> Available --> Mode
    Mode -->|Dynamic QR| Dynamic --> Confirm
    Mode -->|Static QR| StaticEnabled
    StaticEnabled -->|Enabled| Static --> Confirm
    StaticEnabled -->|Unavailable| Stop
    Confirm --> Pay
  end

  subgraph result["Payment results and recovery"]
    Accepted["Save the payment ID after acceptance"]
    Webhook["Receive scan_pay.order.update<br/>Verify the signature and deduplicate by event_id"]
    Detail["GET /transactions/{id} to look up the original payment"]
    Lookup["Look up the payment under its original account<br/>GET /transactions?callId=original payment call ID"]
    Found{"Was the original payment found?"}
    Retry["Keep the original callId and request<br/>Retry unchanged as needed or contact the platform"]
    Status["Apply the latest status and fundsStatus<br/>Show success when status=completed"]
    Webhook --> Status
    Webhook -->|Conflicting or out-of-order status| Detail
    Accepted -->|Webhook delayed or status needs checking| Detail --> Status
    Lookup --> Found
    Found -->|Found| Status
    Found -->|Still missing| Retry
  end

  Capabilities --> Decode
  Pay -->|Acceptance received| Accepted
  Pay -.->|Asynchronous platform webhook| Webhook
  Pay -->|Timeout or unknown result| Lookup

Scan Pay paths in this diagram use the /open-api/v1/scan-pay prefix. Static QR payments reuse the original channel preparation order. If a static quote times out, recover it using the original quote callId and request parameters. If a payment times out, look it up using the original payment callId. See Static QR quoting and Payment lookup after a timeout.

1. Before you start

Confirm the following with the platform before integration testing.

ItemRequirement
API accountConfirm whether you use CaaS or BAAS. Each has separate activation, credentials, and permissions.
Scan Pay permissionYour API configuration must explicitly include scan_pay, labeled Scan Pay in Admin. This also applies to existing credentials.
Funding modeConfirm which account funds and owns the orders. api_owner uses the API primary account. White-label payer uses the payer sub-account.
Entities and walletsExisting API authorization rules apply. Partners using explicit_permissions must prepare a KYC-approved payer entity and usable balance through an approved process.
Environment and credentialsObtain the environment's API base URL, AppID, AppSecret, and server egress IP allowlist requirements from the platform.
Business scopeConfirm supported merchant countries, collection currencies, QR schemes, and crypto wallet (cw) debit currencies.
Payment limitsConfirm the debit currency, per-payment limit, and daily limit for each payer with the platform.
Payment notificationsRegister an HTTPS endpoint on the API primary account and verify signatures using the AppID from that webhook configuration.

To activate Scan Pay, an administrator goes to Account Configuration → API Configuration, selects Scan Pay for the relevant CaaS or BAAS configuration, saves, and confirms the saved setting. Activation retains the existing permissions, Key/Secret, and permission mode. Channel access and payment limits still require approval. Check capabilities for the enabled features.

The platform's operations team manages channel credentials, routing, configuration files, and deployment. Supported countries, currencies, payment limits, and channels are controlled by platform configuration.

2. General conventions

2.1 URLs, identity, and field formats

  • Set BASE_URL to the HTTPS origin provided for your environment, excluding /open-api/v1. Keep credentials and resource IDs separate for testing and production.
  • Send Authorization: Bearer <access_token> on business requests. Keep the token on the partner server.
  • Send dgp-entity-id: <individual entity UUID> with POST /decodes to identify the payer for KYC. The payer must be active, unfrozen, KYC-approved, and affiliated with the API primary account.
  • Requirements, funding source, quote, and payment requests identify the payer from decodeId or quoteId. If you include dgp-entity-id, it must match that payer.
  • Use the Bearer token for GET /capabilities. For payment lookups, include the entity header only for orders that belong to the payer sub-account. See section 9.3. Entity management uses the token's primary account context. See section 5 for wallet requests.
  • Business fields use camelCase. Token fields grant_type, access_token, expires_in, and token_type and webhook fields event_id and event_identifier retain their existing snake_case names.
  • Use UUIDs for decodeId, quoteId, balanceId, payment details id, and related path parameters. Use the payment UUID for GET /transactions/{id}. The display reference idNo is a separate string.
  • Use ISO 8601 timestamps with a time zone, such as 2026-11-12T08:00:00Z or 2026-11-12T16:00:00+08:00. Request timestamp fields have a maximum length of 40 characters.
  • Send amounts as plain decimal strings where possible and use a decimal library for calculations. Positive amounts allow up to 12 integer digits and 8 fractional digits. The quote input merchantAmount has an additional maximum of 1000000000. The API accepts JSON numbers that can be safely represented and satisfy the same constraints. Scientific notation strings, negative or zero amounts, and unnecessary leading zeros are rejected. Currency precision and business limits may be stricter.
  • Scan Pay request schemas reject unknown fields. Follow the documented body and query schemas. Leave out fields such as accountId, userId, channel parameters, and client-calculated rates or fees.

2.2 HTTP and business results

Standard success responses use the following envelope. Endpoint-specific content appears in data.

{
  "code": 0,
  "message": "",
  "timestamp": 1794470400000,
  "requestId": "platform-trace-id",
  "data": {}
}

Parse data using the endpoint's schema. timestamp is in milliseconds. Provide requestId when troubleshooting with the platform.

ResultWhat it means
Successful GETHTTP 200 with code=0.
Successful Scan Pay POSTHTTP 201 with code=0, including idempotent replays and payments still in processing.
Final payment successThe payment details or a verified webhook show data.status=completed.
HTTP 201, code=0, status=processingThe platform has accepted the payment. Show the payer that it is processing.
HTTP 4xx/5xx or network timeoutFollow section 11 and first determine whether the original payment was accepted.

Use status, fundsStatus, and refundStatus to determine the payment and funding results. Error response fields can vary depending on whether authentication, validation, or rate limiting rejected the request. Retain the HTTP status and any available business code and requestId.

2.3 Call IDs and retries

Every Scan Pay POST body must include a callId of 6–50 ASCII letters, digits, underscores, or hyphens, matching ^[A-Za-z0-9_-]{6,50}$. Generate a distinct callId for each operation, including decoding, submitting additional information, quoting, and paying. Retries of the same operation must preserve the original callId, request content, and payer context.

SituationPartner action
Same callId and request for a recorded operationThe API returns the original resource or result. A payment replay returns the current details of the original payment.
Changed parameters with the same callId after acceptance or possible side effectsExpect a conflict, usually HTTP 409 with 970009. Look up the original request before proceeding.
Payment explicitly rejected before local acceptanceThe platform leaves the callId and quote available for retry. After resolving the issue, check that the quote is still valid.
Timeout, connection loss, 5xx, or 970012The outcome is uncertain. Save the original request. For a payment, look up the original callId first and retry the unchanged request if needed.
Decode or quote returns 970012The original operation is unresolved, and an identical retry may return the same code. A static quote may already have created a preparation order. Recover it with the original quote callId. Keep the same call ID and decodeId to avoid automatically recreating the channel order.

Use the body field callId as the idempotency identifier. The payment record stores and validates its call ID, while decoding and quoting each store their own call ID and request digest. Keep the business callId and the resource IDs returned by the API. Before sending a request for the first time, persist the operation type, payer, callId, and complete request. A fresh call ID on every HTTP retry breaks idempotency. Check the entity and wallet creation contracts separately for their own idempotency guarantees.

2.4 Run the examples

The examples use Bash, curl, jq, and openssl. Load the following variables from a secrets manager or a secure local environment. Keep real values out of this guide, source control, and public logs.

set -euo pipefail
: "${BASE_URL:?Set the API origin provided for your environment}"
: "${APPID:?Set the AppID for this environment}"
: "${APP_SECRET:?Load the AppSecret from secure storage}"
export BASE_URL APPID APP_SECRET

new_call_id() { printf '%s_%s' "$1" "$(openssl rand -hex 12)"; }

Run the callId generation steps once per new operation. In production, persist each request in a durable task record and retrieve it directly when retrying. The examples store sensitive results in shell variables. Avoid curl -v or printing complete tokens, identity document fields, or QR data.

3. Get an access token

Call POST /open-api/v1/auth/access_token without a Bearer or entity header.

FieldType / requiredDescription
grant_typestring, requiredUse the singular value client_credential.
appidstring, requiredAppID provided by the platform.
secretstring, requiredAppSecret associated with the AppID.
TOKEN_RESPONSE=$(jq -n '{grant_type:"client_credential",appid:env.APPID,secret:env.APP_SECRET}' |
  curl --silent --show-error --fail-with-body \
    -X POST "$BASE_URL/open-api/v1/auth/access_token" \
    -H 'Content-Type: application/json' --data-binary @-)
ACCESS_TOKEN=$(printf '%s' "$TOKEN_RESPONSE" | jq -er 'select(.code == 0) | .data.access_token')
export ACCESS_TOKEN

On success, data contains access_token, expires_in: 7200, and token_type: "bearer". Cache the token for the returned lifetime in seconds and refresh it before expiry. Coordinate refreshes if multiple instances share the same cache. Treat the token as opaque. The platform evaluates permissions.

The gateway typically returns HTTP 403 for an invalid or expired Bearer token. HTTP 403 can also indicate a permission or IP allowlist issue. Check the cached token's expiry first. If the token is still valid, check API permissions, IP allowlisting, business type, and payer ownership.

4. Prepare the individual payer entity and complete KYC

If the payer already has a KYC-approved individual entity on the platform, continue to section 5. The examples in this section apply to partners with access to the entity APIs. Creating an individual entity requires sub_account. The entity management endpoints in this section are unavailable to explicit_permissions credentials.

4.1 Create an individual entity

Call POST /open-api/v1/entities/person with the Bearer header and no dgp-entity-id header.

FieldType / requiredDescription
emailstring, requiredThe payer's valid email address.
callIdstring, requiredA partner reference of 6–50 characters for this creation request. The example uses the same safe character set as Scan Pay.
firstNameEn / lastNameEnstring, optionalEnglish given name and family name. Provide both when used.
ipAddressstring, optionalThe user's most recent login IP. Supply a valid IP address.
: "${PAYER_EMAIL:?Set the email address for the individual payer}"
ENTITY_CALL_ID=$(new_call_id entity)
ENTITY_RESPONSE=$(jq -n --arg callId "$ENTITY_CALL_ID" --arg email "$PAYER_EMAIL" \
  '{callId:$callId,email:$email}' |
  curl --silent --show-error --fail-with-body \
    -X POST "$BASE_URL/open-api/v1/entities/person" \
    -H "Authorization: Bearer $ACCESS_TOKEN" \
    -H 'Content-Type: application/json' --data-binary @-)
ENTITY_ID=$(printf '%s' "$ENTITY_RESPONSE" | jq -er 'select(.code == 0) | .data.id')
export ENTITY_ID

Save the mapping between data.id and the partner's user ID. Use data.id, the platform's individual entity ID, as the dgp-entity-id header when decoding a QR code. The creation response also includes callId, account status, kycStatus, and other entity details.

If entity creation times out, look it up by the original callId before retrying. Keep the original reference and email address.

curl --silent --show-error --fail-with-body --get \
  "$BASE_URL/open-api/v1/entities" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  --data-urlencode "callId=$ENTITY_CALL_ID" \
  --data-urlencode 'page=1' --data-urlencode 'take=20'

4.2 Get the KYC link

Call POST /open-api/v1/entities/auth-url with entityId to start individual KYC. Omit dgp-entity-id so an entity with incomplete KYC can still use this management workflow.

KYC_RESPONSE=$(jq -n --arg entityId "$ENTITY_ID" '{entityId:$entityId}' |
  curl --silent --show-error --fail-with-body \
    -X POST "$BASE_URL/open-api/v1/entities/auth-url" \
    -H "Authorization: Bearer $ACCESS_TOKEN" \
    -H 'Content-Type: application/json' --data-binary @-)
KYC_AUTH_URL=$(printf '%s' "$KYC_RESPONSE" | jq -er 'select(.code == 0) | .data.authUrl')

Direct the payer to data.authUrl to complete verification. Follow the platform's rules for displaying and forwarding identity verification links. The optional businessTypes field applies to existing business types. Use the standard individual KYC flow for Scan Pay and omit scan_pay from that field.

4.3 Check the KYC result

curl --silent --show-error --fail-with-body --get \
  "$BASE_URL/open-api/v1/entities" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  --data-urlencode "id=$ENTITY_ID" \
  --data-urlencode 'page=1' --data-urlencode 'take=20'

The entity list returns {list,total,current} in data. Find the entity in data.list. Continue to payment only when status=active and kycStatus=completed. Review completion is reported separately from the payer's return from the verification page. Use existing entity status notifications or poll the list endpoint infrequently. Verify entity notifications with the AppID configured for their recipient. Verify Scan Pay payment notifications using the API primary account's webhook configuration, as described in section 10.

5. Prepare funds and wallets

Both funding modes use a platform crypto wallet balance (cw). The CaaS or BAAS API credential configuration determines which account funds and owns the payment.

Funding modeFunding accountOrder ownerHeaders for wallet and deposit address requests
api_owner (default)The partner’s primary API account wallet. Payers under the same partner can share funds held in that account.API primary accountAuthorization: Bearer …
payer (white-label)The payer sub-account wallet identified by dgp-entity-id. Each payer uses their own available balance.Payer sub-accountAuthorization: Bearer … and dgp-entity-id

In both modes, send the payer’s dgp-entity-id when decoding the QR code to identify the payer for KYC. Requirements, funding source, quote, and payment requests identify that payer from the decode or quote. An optional entity header must match the original payer. The platform applies the daily limit to the individual payer on the original quote in both funding modes. After decoding the QR code, use GET /funding-sources?decodeId=… to check the available balances. When the funding account has exactly one CW balance eligible for automatic selection, you can request a quote directly. The platform configures the funding mode per API credential. See quote expiry for how a mode change affects outstanding quotes, user confirmations, and accepted payments.

If you already have an available balance, skip to section 6. The wallet examples below require access to the existing wallet APIs. In api_owner mode, use the primary API account’s Bearer token for wallet requests. In payer mode, add the payer entity header. With explicit_permissions credentials, deposit funds through the approved funding process first.

5.1 List or create wallets

Use GET /open-api/v1/crypto-wallet/wallets to list wallets.

SCAN_PAY_FUNDING_MODE=${SCAN_PAY_FUNDING_MODE:-api_owner}
WALLET_HEADERS=(-H "Authorization: Bearer $ACCESS_TOKEN")
if [ "$SCAN_PAY_FUNDING_MODE" = 'payer' ]; then
  WALLET_HEADERS+=(-H "dgp-entity-id: $ENTITY_ID")
fi
curl --silent --show-error --fail-with-body --get \
  "$BASE_URL/open-api/v1/crypto-wallet/wallets" \
  "${WALLET_HEADERS[@]}" \
  --data-urlencode 'page=1' --data-urlencode 'take=20'

Filter by currency, callId, or nickname. The response list is in data.list. Each wallet has id, currency, nickname, callId, and balance. Use balance.id as the debit balance ID.

To create a wallet, use POST /open-api/v1/crypto-wallet/wallets. This endpoint accepts USDT and USDC. Use a currency approved for your integration and confirm that it is enabled for Scan Pay debits.

: "${WALLET_CURRENCY:?Set the approved wallet currency to USDT or USDC}"
WALLET_CALL_ID=$(new_call_id wallet)
WALLET_RESPONSE=$(jq -n --arg callId "$WALLET_CALL_ID" --arg currency "$WALLET_CURRENCY" \
  '{callId:$callId,currency:$currency,nickname:"Scan Pay"}' |
  curl --silent --show-error --fail-with-body \
    -X POST "$BASE_URL/open-api/v1/crypto-wallet/wallets" \
    "${WALLET_HEADERS[@]}" \
    -H 'Content-Type: application/json' --data-binary @-)
WALLET_ID=$(printf '%s' "$WALLET_RESPONSE" | jq -er 'select(.code == 0) | .data.id')
WALLET_BALANCE_ID=$(printf '%s' "$WALLET_RESPONSE" | jq -er 'select(.code == 0) | .data.balance.id')

Wallet creation requires callId and currency. The optional nickname must have 1–100 characters. If creation times out, look up the original callId in the wallet list before taking further action. The wallet endpoints have their own idempotency behavior.

5.2 Get a deposit address

: "${CHAIN:?Set the wallet network to a value approved by the platform}"
curl --silent --show-error --fail-with-body --get \
  "$BASE_URL/open-api/v1/crypto-wallet/wallets/address" \
  "${WALLET_HEADERS[@]}" \
  --data-urlencode "walletId=$WALLET_ID" --data-urlencode "chain=$CHAIN"

Set walletId to the wallet’s id and chain to a case-sensitive network value approved by the platform, such as Ethereum. The response data includes walletId, chain, address, and optionally tokenContractAddress. Deposit only using an approved asset, network, and contract. Wait for the required network confirmations and compliance checks and for the funds to be credited.

Use the wallet’s id to request a deposit address. To specify a debit balance in a quote, use the wallet’s balance.id and confirm it appears in funding-sources for the current decode. Once the deposit is credited, confirm that the balance is available for payment.

6. Check capabilities and payment limits

6.1 Check capabilities for the API credential

CAPABILITIES_RESPONSE=$(curl --silent --show-error --fail-with-body \
  "$BASE_URL/open-api/v1/scan-pay/capabilities" \
  -H "Authorization: Bearer $ACCESS_TOKEN")
data fieldTypeHow to use it
available / unavailableReasonboolean / string or nullDisable the Scan Pay option when available is false. ROUTE_NOT_VALIDATED means the route is unavailable.
fundingSourceTypesstring[]Currently internal_balance.
balanceTypesstring[]Only platform crypto wallet balances (cw) are supported. Currently returns ["cw"].
merchantCurrencies / countries / qrSchemesstring[]Optional platform or customer-level restrictions; returns [] when unrestricted.
qrModesstring[]Supported QR modes (dynamic, static).
staticQuoteModestring, optionalchannel_prepare is returned when static QR is enabled. A static quote creates a channel preparation order.
quoteTtlSecondsnumberMaximum local quote lifetime, currently 60 seconds. Use the quote’s actual expireAt.
supportsRefunds / supportsCancellationbooleanBoth are currently false. Refund and cancellation endpoints are unavailable.

You can cache capabilities briefly. The platform validates current availability when you submit a quote or payment. Use the countries, currencies, and wallet networks confirmed for your environment.

6.2 Debit and balance validation

When accepting a payment, the platform atomically validates and debits the quoted payAmount from the selected CW balance. Customer-level per-payment and daily limits will be managed through database customer configuration in a future release.

7. Decode the QR code, collect required information, and select a balance

7.1 Decode a QR code

Use POST /open-api/v1/scan-pay/decodes to decode a QR code.

FieldType / RequiredRule
callIdstring, requiredCall ID for this decode operation.
qrPayloadstring, requiredRaw text captured from the merchant QR code, 1–4096 characters after trimming, with no NUL characters. Send the text obtained from the scan.
: "${QR_PAYLOAD:?Set the actual text scanned from the merchant QR code}"
DECODE_CALL_ID=$(new_call_id decode)
DECODE_REQUEST=$(jq -n --arg callId "$DECODE_CALL_ID" --arg qrPayload "$QR_PAYLOAD" \
  '{callId:$callId,qrPayload:$qrPayload}')
DECODE_RESPONSE=$(printf '%s' "$DECODE_REQUEST" |
  curl --silent --show-error --fail-with-body \
    -X POST "$BASE_URL/open-api/v1/scan-pay/decodes" \
    -H "Authorization: Bearer $ACCESS_TOKEN" -H "dgp-entity-id: $ENTITY_ID" \
    -H 'Content-Type: application/json' --data-binary @-)
DECODE_ID=$(printf '%s' "$DECODE_RESPONSE" | jq -er 'select(.code == 0) | .data.decodeId')
data fieldTypeMeaning
decodeId / expireAtUUID / timestampServer-side decode session and its expiry time. The local session currently lasts up to 300 seconds.
qrModestringdynamic, static, or unknown. Check the returned mode against capabilities.
merchantAmountdecimal string or nullMerchant amount for a dynamic QR code. Can be null for static QR.
merchantCurrencystringCurrency the merchant receives.
merchantName / merchantCountrystring, optionalMerchant name and country.
mccstring, optionalMerchant category code supplied by the provider.
qrSchemestring, optionalQR payment network, such as VIETQR.
requirementsobjectCurrent status and form for additional information, described in the next section.

Decoding leaves merchant payment for the payment step. Continue with the server-issued decodeId. Keep decodeRaw, channel order IDs, and locally modified decode data out of subsequent requests. For dynamic QR, the server snapshot determines the merchant amount and currency.

7.2 Check and collect required payer information

The initial decode response includes requirements. Use this request when you need to refresh the form.

REQUIREMENTS_RESPONSE=$(curl --silent --show-error --fail-with-body \
  "$BASE_URL/open-api/v1/scan-pay/decodes/$DECODE_ID/requirements" \
  -H "Authorization: Bearer $ACCESS_TOKEN")
FieldMeaning
statusready allows you to request a quote. action_required means the payer needs to provide additional information. blocked means the payer must first complete basic KYC.
versionCurrent form version. Pass it unchanged as the JSON integer requirementVersion when submitting the form.
kycRequiredBoolean. When true, the payer must complete basic individual KYC (section 4) first.
missingKycFieldsArray of missing KYC field keys.
fieldsCurrent array of allowed fields. Each entry has key, label, type, required, and order.
Optional field settingsplaceholder, options (label/value), defaultValue, description, textConfig, and dateConfig.
textConfigMay include maxlength, showWordLimit, validationRule, and validationRuleLabel. Use them to display and validate text fields.
dateConfigContains type, format, valueFormat, and clearable. Collect dates in the returned format.

Render text, select, or date controls as indicated by the form. Collect the user's values into a JSON object using the keys in fields[].key. In the example below, REQUIREMENT_FIELDS_JSON comes from the current form.

: "${REQUIREMENT_FIELDS_JSON:?Set the JSON object containing the values entered in the current form}"
REQUIREMENT_VERSION=$(printf '%s' "$REQUIREMENTS_RESPONSE" | jq -er 'select(.code == 0) | .data.version')
REQUIREMENTS_CALL_ID=$(new_call_id requirements)
REQUIREMENTS_REQUEST=$(jq -n --arg callId "$REQUIREMENTS_CALL_ID" \
  --argjson requirementVersion "$REQUIREMENT_VERSION" --argjson fields "$REQUIREMENT_FIELDS_JSON" \
  '{callId:$callId,requirementVersion:$requirementVersion,fields:$fields}')
REQUIREMENTS_RESPONSE=$(printf '%s' "$REQUIREMENTS_REQUEST" |
  curl --silent --show-error --fail-with-body \
    -X POST "$BASE_URL/open-api/v1/scan-pay/decodes/$DECODE_ID/requirements" \
    -H "Authorization: Bearer $ACCESS_TOKEN" \
    -H 'Content-Type: application/json' --data-binary @-)

Submit callId, requirementVersion (an integer from 1 to 2147483647), and fields (1–64 key-value pairs). Use the keys returned by the current form. Each value must be a string of up to 2048 characters and meet any stricter field rules for length, allowed values, or dates. The platform validates the submission. Restrict the request to the current form fields.

The response returns the updated requirements. Proceed only when status=ready. For a version conflict (970009), GET the form again, ask the user to confirm any required changes, and submit with a new callId. If the status is blocked, follow section 4 to complete KYC and then refresh the form. If the decode has expired, start a new scan session.

7.3 List eligible debit balances

FUNDING_RESPONSE=$(curl --silent --show-error --fail-with-body --get \
  "$BASE_URL/open-api/v1/scan-pay/funding-sources" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  --data-urlencode "decodeId=$DECODE_ID")

The response returns an array directly in data. Each item has the following fields.

FieldTypeMeaning
balanceIdUUIDDebit balance ID used for quoting.
balanceTypestringcw, a platform crypto wallet balance.
currencystringDebit currency.
availabledecimal stringAvailable balance at the time of the query. It may be negative. Funds are checked again at quote and payment admission.
availableForPaymentbooleanWhether the current balance status allows payment. Funds and payment limits still apply.
unavailableReasonstring or nullFor example, BALANCE_INACTIVE.

To specify a wallet, select a currency from data[], check availableForPayment=true, and pass that item’s balanceId to POST /quotes. If you started with a wallet from section 5, match its balance.id to the balanceId here. The payment request uses quoteId to reference the same balance.

If you omit balanceId, the platform considers only the funding account for the configured mode. An eligible balance must belong to a platform crypto wallet (cw), use an enabled Scan Pay debit currency, have a status that allows payment, and show an available balance greater than zero. The platform selects the balance when exactly one qualifies. If several qualify, HTTP 400 / 970017 asks you to specify balanceId. If none qualify, HTTP 400 / 970018 asks you to fund an available CW balance. The quote still checks whether the selected wallet can cover the full payment amount.

8. Quote and user confirmation

8.1 Request a quote

For a dynamic QR code, check that qrMode=dynamic and capabilities.qrModes includes dynamic. For a static QR code, follow section 8.2 to confirm that static and channel_prepare are enabled, then ask the user to enter the merchant amount. Both modes use POST /open-api/v1/scan-pay/quotes.

FieldType / RequiredRule
callIdstring, requiredCall ID for this quote operation.
decodeIdUUID, requiredCurrent valid decode session.
balanceIdUUID, optionalIdentifies an available CW balance for the current funding account. Omit this field when exactly one balance qualifies. Supply it when multiple balances qualify.
merchantAmountdecimal string, required for static QRFor static QR, use the merchant amount the user entered. For dynamic QR, omit the field to use the server’s decoded amount. If you supply it, it must match.
merchantCurrencystring, optionalOmit this field to use the server’s decoded currency. If you supply it, it must match.
# To specify a wallet, set BALANCE_ID to the user's selection from funding-sources.
QR_MODE=$(printf '%s' "$DECODE_RESPONSE" | jq -er 'select(.code == 0) | .data.qrMode')
SUPPORTED_QR_MODE=$(printf '%s' "$CAPABILITIES_RESPONSE" | jq -er --arg mode "$QR_MODE" \
  'select(.code == 0 and .data.available == true) | .data.qrModes[] | select(. == $mode)')
QUOTE_CALL_ID=$(new_call_id quote)
if [[ "$QR_MODE" == "static" ]]; then
  : "${MERCHANT_AMOUNT:?Set the merchant amount entered by the user as a plain decimal string}"
  STATIC_QUOTE_MODE=$(printf '%s' "$CAPABILITIES_RESPONSE" | jq -er \
    'select(.code == 0 and .data.staticQuoteMode == "channel_prepare") | .data.staticQuoteMode')
  QUOTE_REQUEST=$(jq -n --arg callId "$QUOTE_CALL_ID" --arg decodeId "$DECODE_ID" \
    --arg balanceId "${BALANCE_ID:-}" --arg merchantAmount "$MERCHANT_AMOUNT" \
    '{callId:$callId,decodeId:$decodeId,merchantAmount:$merchantAmount}
     + (if $balanceId == "" then {} else {balanceId:$balanceId} end)')
else
  QUOTE_REQUEST=$(jq -n --arg callId "$QUOTE_CALL_ID" --arg decodeId "$DECODE_ID" --arg balanceId "${BALANCE_ID:-}" \
    '{callId:$callId,decodeId:$decodeId}
     + (if $balanceId == "" then {} else {balanceId:$balanceId} end)')
fi
QUOTE_RESPONSE=$(printf '%s' "$QUOTE_REQUEST" |
  curl --silent --show-error --fail-with-body \
    -X POST "$BASE_URL/open-api/v1/scan-pay/quotes" \
    -H "Authorization: Bearer $ACCESS_TOKEN" \
    -H 'Content-Type: application/json' --data-binary @-)
QUOTE_ID=$(printf '%s' "$QUOTE_RESPONSE" | jq -er 'select(.code == 0) | .data.quoteId')
QUOTE_EXPIRE_AT=$(printf '%s' "$QUOTE_RESPONSE" | jq -er 'select(.code == 0) | .data.expireAt')

The quote returns the converted amount, fee, and total debit for the merchant amount. A dynamic QR quote calculates the price directly. A static QR quote creates a channel preparation order and queries that order for the price without paying the merchant or freezing channel funds. Submit the payment separately as described in section 9.

The quote uses flat fields in data.

FieldTypeHow to display or use it
quoteId / expireAtUUID / timestampPayment reference and the actual expiry time for this quote.
balanceId / balanceType / currencyUUID / string / stringDebit balance and currency bound to this quote, including an automatically selected balance.
merchantAmount / merchantCurrencydecimal string / stringAmount and currency the merchant will receive.
merchantName / merchantCountry / mcc / qrSchemestring, optionalMerchant and QR information. See Section 7.1.
feedecimal stringFee in the debit currency.
payAmountdecimal stringTotal debit, used for user confirmation and balance validation.
ratedecimal stringEffective quote rate in units of merchant currency per unit of debit currency, calculated as merchantAmount / (payAmount - fee).
sameCurrencybooleanWhether the merchant and debit currencies match.
requirementsobjectLatest status for additional payer information.

Use the server’s amounts and rates for the quote display and final debit. Quoting leaves funds available in the wallet. The platform checks funds again when accepting payment.

For example, a merchant receives 100000 VND and the payer’s wallet is debited 4.04 USDT, which includes a 0.04 USDT fee. The rate is 25000. For USDC payments, the primary API account must have USDC enabled as its debit currency and the platform must have a valid rate.

A successful quote binds and returns its balanceId. Replaying the same callId with the same request uses the original balance, even if the number of wallets or available funds changes. Submit the associated quoteId for payment. Show the quoted wallet, debit currency, and total on the confirmation page.

8.2 Static QR: Prepare the channel order before quoting

The flow is to decode the QR code, collect the merchant amount from the user, collect any required payer information, select a balance, request a quote, show the total, collect confirmation, and submit payment. At quote time, the platform uses the existing App workflow, createPay → orderQuery, and persists the link between the channel preparation order, the decode, and the quote. Payment reuses the same channel order. Use the standard Scan Pay endpoints to quote and confirm the exact payment amount.

Check capabilities first. Offer static QR payment only when qrModes includes static and staticQuoteMode=channel_prepare. The platform enables this mode after verifying the preparation behavior for the current channel account and environment. Isolated tests and live channel verification are separate. When the capability is unavailable, stop quoting and payment for that code. Only the platform can enable static QR for the route. The platform checks the route, static-mode switch, and decode expiry immediately before sending the preparation request. If any check fails, the platform stops before creating the preparation order.

Use the curl example from section 8.1 and set MERCHANT_AMOUNT to the value the user entered. Use the merchant currency from the server’s decode snapshot. Channel transaction IDs, settlement costs, and original channel responses remain internal to the platform. Tell users that quoting creates a channel preparation order. Ask users to settle on an amount and wallet before requesting the quote.

A decodeId can create at most one channel preparation order. Confirm the amount before the first static quote. Supply the debit balance or let the platform select the only qualifying wallet. After you send the quote request, recover it using the original callId and parameters. If the first request omitted balanceId, omit it on retry. To change the amount or balance, check the original preparation order for a definitive outcome, confirm that no payment was made, then scan again to start a new session.

Static quote replay or changeCurrent handling
Same callId and same requestReturns the original quote or recovers the price using the known preparation order. An unresolved preparation can return 970012.
Same callId and different parameters970009. The platform retains the original preparation.
Same decodeId with a new quote callId, or a changed amount or balance970009. Each decode session allows a single preparation.
New decodeId while preparation for the original QR is unresolved970012. Keep the original request and investigate its outcome.
Preparation contract conflict, early payment, or identity, amount, or channel mismatch970010. The platform isolates the order for investigation. A later ordinary P response leaves the conflict in place.

If the channel order was created but the price lookup failed, or the request timed out, the original quote may return 970012. Keep the original request and retry POST /quotes with the same parameters. If the channel order is known, the platform looks it up using the stored merchant amount and currency and retains the evidence. It then checks the decode expiry, balance, and other conditions before issuing a usable quote. The lookup uses the original channel order. If the decode expires while the channel order is still in preparation, quoting and payment stop for that session. The platform keeps the record and continues checking approximately every 15 minutes, subject to scheduler timing. Late evidence of payment or execution permanently isolates the order for investigation. If the creation request times out and a complete, signed preparation notification arrives later with matching amount and identity, the platform can link the original channel order and recover it by lookup using the original callId. Keep using the original request while the outcome is uncertain. If the session has expired or recovery remains unsuccessful, contact the platform with the original quote callId, payer entity, and requestId. Confirm cancellation with the platform before treating the external order as cancelled.

Use the payment status to show whether the merchant has been paid. If the user abandons the flow, the quote expires, or the local balance is insufficient, a successful static quote still only indicates preparation. Channel preparation orders currently have no public cancellation endpoint. If the channel reports an early payment or execution in progress in conflict with its preparation contract, the platform isolates the request and investigates. Stop the current flow and wait for the outcome before accepting another payment.

8.3 User confirmation and quote expiry

On the confirmation page, show the merchant, merchant amount and currency, the debit balance and currency, fee, payAmount, rate, and the quote expiry. Ask the user to confirm the final payAmount.

Quotes use the actual funding account’s fee settings. If switching funding modes means an outstanding quote points to a different funding account, payment returns 409 / 970003. For dynamic QR, request a quote with the new balance. For static QR, follow section 8.2 to check the original preparation order before starting a new session. Accepted orders keep their original ownership. Look up the original callId within that account's scope. Failure compensation uses the original debit account and ledger entries.

Quotes currently last up to 60 seconds. The actual expireAt is the earliest of the local quote expiry, decode expiry, and channel quote expiry. Use it for the countdown and stop submitting once it expires. A fresh dynamic quote or a new static session after the check in section 8.2 can change the total. Ask the user to confirm again and use a new payment callId. To refresh a static quote, start a new session after confirming the original preparation order’s outcome.

9. Submit a payment and look up the original order

9.1 Submit a payment

Send the request to POST /open-api/v1/scan-pay/payments. The platform identifies the payer from the quote. If you send dgp-entity-id, it must match the payer recorded on that quote.

FieldType / requirementDescription
callIdstring, requiredIdempotency identifier for this payment, unique within the account that owns the order. In primary-account mode, all payers and API credentials under that account share this scope
quoteIdUUID, requiredServer quote that the user just confirmed. The quote must still be valid and unused
PAYMENT_CALL_ID=$(new_call_id payment)
PAYMENT_REQUEST=$(jq -n --arg callId "$PAYMENT_CALL_ID" --arg quoteId "$QUOTE_ID" \
  '{callId:$callId,quoteId:$quoteId}')
# In production, persist PAYMENT_CALL_ID, ENTITY_ID, and PAYMENT_REQUEST before sending.
PAYMENT_RESPONSE=$(printf '%s' "$PAYMENT_REQUEST" |
  curl --silent --show-error --fail-with-body \
    -X POST "$BASE_URL/open-api/v1/scan-pay/payments" \
    -H "Authorization: Bearer $ACCESS_TOKEN" \
    -H 'Content-Type: application/json' --data-binary @-)
PAYMENT_ID=$(printf '%s' "$PAYMENT_RESPONSE" | jq -er 'select(.code == 0) | .data.id')

When accepting a payment, the platform validates the payer entity, its KYC and account status, and the available debit balance. In the default api_owner mode, the order belongs to the API primary account. In white-label payer mode, it belongs to the payer sub-account.

Use the same request structure for a static QR quote backed by a prepared channel order. Send the confirmed quoteId. The platform retrieves the original channel order from the quote snapshot. Supply the platform quote ID as the reference to that order. The platform reuses the existing preparation without another createPay call. Display the reported payment status and show success only after payment details or a verified webhook reports status=completed.

Once a static payment has been accepted and debited, the platform continues to check the original channel order even if permissions or KYC status later change. It starts compensation when there is evidence of final channel failure. If your ability to look up the payment later is revoked, contact the platform to reconcile the original order before taking any further payment action.

9.2 Transaction

Use this Transaction definition for payment acceptance data, transaction detail data, each data.list[] item in the transaction list, and webhook data. The OpenAPI component is OpenApiScanPayTransactionOutput.

FieldTypeDescription
id / idNo / callIdUUID / string / stringPlatform payment ID, display reference, and original partner payment call ID
accountIdUUIDIndividual payer entity ID from the original quote, used for KYC in both funding modes. Accepted transactions retain this payer after the quote expires
quoteIdUUIDBound server quote ID
balanceId / balanceType / currencyUUID / string / stringDebit balance, balance type, and debit currency. New transactions use cw. Historical transactions retain their original balance type
merchantAmount / merchantCurrencydecimal string / stringAmount and currency the merchant receives
merchantName / merchantCountry / mcc / qrSchemestring, optionalMerchant and QR information. See Section 7.1
fee / payAmountdecimal string / decimal stringFee and total debit in the debit currency
ratedecimal stringEffective rate in units of merchant currency per unit of debit currency, calculated as merchantAmount / (payAmount - fee)
statusstringMerchant payment status. See the table below
trxStatusstringUnderlying status for reconciliation, one of pending, completed, and failed. Use status for the merchant payment outcome
fundsStatusstringnot_debited, debited, compensation_pending, or compensated
typestringscan_pay for payment or scan_pay_refund for a payment in compensation or already compensated
refundStatusstring or nullnull when there is no refund, pending during compensation, or completed after the funds have been returned
preTransactionIdUUID or nullAlways present. null for a payment. The original payment order ID during and after compensation
failedReasonstring or nullUser-facing explanation. Use status, fundsStatus, and refundStatus when branching in code
createdAt / completedAttimestamp, with completedAt nullableCreation and completion timestamps
statusHow to handle it
processingThe platform has accepted the request and awaits the channel result. Show processing and look up the original payment
completedThe merchant payment succeeded. Show success and reconcile using id or idNo
manual_reviewThe outcome is uncertain or the evidence conflicts. Look up the original payment. If the outcome is still unclear, contact the platform before starting a new payment
failedThe merchant payment failed. Check fundsStatus and refundStatus to determine whether funds have been returned before starting a new payment
pending / expired / refundedReserved statuses in the schema. The current API supports payment submission and lookup. Creating an unpaid order, canceling a payment, and refunding a successful payment are outside its current scope

When fundsStatus=compensation_pending, wait for compensation and continue checking the original payment. When status=failed and fundsStatus=compensated (refundStatus=completed), the platform has automatically returned the failed debit to the original funding balance (the original CW wallet for a CW payment), and you may obtain a new quote and ask the user to confirm before starting a new payment.

Use the original callId and the account that owned the order at acceptance to look up previously accepted payments. Their details retain the original funding balance type, and failed debits are compensated to that balance. To replay a payment accepted under the current request format, reuse its callId and exact request. If a new payment references a historical quote tied to a non-CW balance, obtain a new CW quote and ask the user to confirm it. If a static QR session already created a prepared channel order, check it as described in Section 8.2 before starting a new session.

This excerpt shows the accepted payment. Refund lookup and webhook for the same order

{
  "code": 0,
  "message": "",
  "timestamp": 1794470398000,
  "requestId": "mock-scan-pay-request-001",
  "data": {
    "id": "00000000-0000-4000-8000-000000000002",
    "idNo": "1000000000000000001",
    "callId": "payment_example_001",
    "accountId": "11111111-1111-4111-8111-111111111111",
    "type": "scan_pay",
    "status": "processing",
    "fundsStatus": "debited",
    "refundStatus": null,
    "preTransactionId": null,
    "currency": "USDT",
    "merchantCurrency": "VND",
    "merchantAmount": "100000",
    "fee": "0.04",
    "payAmount": "4.04",
    "rate": "25000",
    "qrScheme": "VIETQR"
  }
}

9.3 Look up a payment by its platform ID

Use any CaaS or BAAS credential with scan_pay enabled on the same API primary account. Omit dgp-entity-id to look up orders owned by the primary account. For a white-label payer sub-account, supply that sub-account's dgp-entity-id to limit the lookup to its orders. A later change to the funding mode leaves earlier orders in their original account scope.

The examples below use the primary account by default. Set ORDER_ENTITY_ID to the original order owner's sub-account entity ID to look up a white-label order. Reuse these headers in sections 9.4 and 9.5.

PAYMENT_SCOPE_HEADERS=(-H "Authorization: Bearer $ACCESS_TOKEN")
if [[ -n "${ORDER_ENTITY_ID:-}" ]]; then
  PAYMENT_SCOPE_HEADERS+=(-H "dgp-entity-id: $ORDER_ENTITY_ID")
fi
curl --silent --show-error --fail-with-body \
  "$BASE_URL/open-api/v1/scan-pay/transactions/$PAYMENT_ID" \
  "${PAYMENT_SCOPE_HEADERS[@]}"

The HTTP 200 response uses Transaction for data. Transaction definition

9.4 Look up the original payment after a timeout

curl --silent --show-error --fail-with-body --get \
  "$BASE_URL/open-api/v1/scan-pay/transactions" \
  "${PAYMENT_SCOPE_HEADERS[@]}" \
  --data-urlencode "callId=$PAYMENT_CALL_ID" \
  --data-urlencode 'page=1' --data-urlencode 'take=20'

Retrieve the original payment from data.list. Treat an empty list as inconclusive. If the first request timed out or returned no definitive result, keep the original PAYMENT_REQUEST and retry it as sent or ask the platform to verify it. Reuse the same callId throughout recovery. If permissions or account status prevent a later lookup, keep the original payment reference and ask the platform for help before taking any further payment action.

9.5 List transactions by creation time

Use GET /open-api/v1/scan-pay/transactions to look up a payment by exact callId or list transactions in a creation-time window of up to 31 days. Use the account scope and headers described in section 9.3.

: "${CREATED_AT_FROM:?Set the start time, including its time zone}"
: "${CREATED_AT_TO:?Set the end time within 31 days of the start time}"
curl --silent --show-error --fail-with-body --get \
  "$BASE_URL/open-api/v1/scan-pay/transactions" \
  "${PAYMENT_SCOPE_HEADERS[@]}" \
  --data-urlencode "createdAtFrom=$CREATED_AT_FROM" --data-urlencode "createdAtTo=$CREATED_AT_TO" \
  --data-urlencode 'page=1' --data-urlencode 'take=20'
Query parameterRule
pageStarts at 1. The default is 1 and the maximum is 100000000
takeFrom 1 to 100. The default is 20
callIdExact payment call ID. May be supplied without time bounds
createdAtFrom / createdAtToSupply both unless looking up an exact callId. The end of the window is inclusive and at or after the start. The maximum span is 31 days

If you supply time bounds with an exact callId, both bounds must still be valid. The query uses the exact call ID as its primary filter. Results are sorted by creation time descending, then ID descending. Only the pagination and lookup parameters listed here are supported.

The response data contains {list,total,current}. Each list item uses Transaction. total is the number of matching records, and current is the number of records on the current page. Increase the request's page to fetch the next page. Because new records may arrive during pagination, reconcile using fixed historical time windows, allow adjacent windows to overlap as needed, and deduplicate by id. Transaction definition

10. Payment status webhook

10.1 Destination and event format

The platform sends payment events as HTTP POST requests to the HTTPS endpoint registered on the API primary account, including events for white-label sub-account orders. The platform first checks the primary account's CaaS configuration for an AppID and endpoint, then its BAAS configuration. The endpoint must be directly accessible from the public internet.

The event identifier is scan_pay.order.update. Use event_id to deduplicate deliveries and occurredAt to see when the event was created. Webhook data uses the Transaction from Section 9.2. In OpenAPI, OpenApiScanPayWebhookOutput.data refers to the same component. Transaction definition

The two mocks below show a lookup response and a webhook for the same failed payment after compensation completes. Their data objects match, and preTransactionId points to the original payment.

Lookup response

GET /open-api/v1/scan-pay/transactions/{id} returns HTTP 200. Use data.preTransactionId from the refund webhook as id in the request path.

{
  "code": 0,
  "message": "",
  "timestamp": 1794470401000,
  "requestId": "mock-scan-pay-request-002",
  "data": {
    "id": "00000000-0000-4000-8000-000000000002",
    "idNo": "1000000000000000001",
    "callId": "payment_example_001",
    "accountId": "11111111-1111-4111-8111-111111111111",
    "quoteId": "00000000-0000-4000-8000-000000000003",
    "type": "scan_pay_refund",
    "status": "failed",
    "trxStatus": "failed",
    "fundsStatus": "compensated",
    "refundStatus": "completed",
    "preTransactionId": "00000000-0000-4000-8000-000000000002",
    "balanceId": "00000000-0000-4000-8000-000000000005",
    "balanceType": "cw",
    "currency": "USDT",
    "merchantAmount": "100000",
    "merchantCurrency": "VND",
    "merchantName": "Demo Market",
    "merchantCountry": "VN",
    "mcc": "5411",
    "qrScheme": "VIETQR",
    "fee": "0.04",
    "payAmount": "4.04",
    "rate": "25000",
    "failedReason": "Scan Pay payment failed.",
    "createdAt": "2026-11-12T07:59:58.000Z",
    "completedAt": null
  }
}

Webhook

{
  "event_id": "00000000-0000-4000-8000-000000000001",
  "event_identifier": "scan_pay.order.update",
  "schemaVersion": 1,
  "occurredAt": "2026-11-12T08:00:00.000Z",
  "data": {
    "id": "00000000-0000-4000-8000-000000000002",
    "idNo": "1000000000000000001",
    "callId": "payment_example_001",
    "accountId": "11111111-1111-4111-8111-111111111111",
    "quoteId": "00000000-0000-4000-8000-000000000003",
    "type": "scan_pay_refund",
    "status": "failed",
    "trxStatus": "failed",
    "fundsStatus": "compensated",
    "refundStatus": "completed",
    "preTransactionId": "00000000-0000-4000-8000-000000000002",
    "balanceId": "00000000-0000-4000-8000-000000000005",
    "balanceType": "cw",
    "currency": "USDT",
    "merchantAmount": "100000",
    "merchantCurrency": "VND",
    "merchantName": "Demo Market",
    "merchantCountry": "VN",
    "mcc": "5411",
    "qrScheme": "VIETQR",
    "fee": "0.04",
    "payAmount": "4.04",
    "rate": "25000",
    "failedReason": "Scan Pay payment failed.",
    "createdAt": "2026-11-12T07:59:58.000Z",
    "completedAt": null
  }
}

Refund snapshots during and after compensation retain the original payment's id and callId. The transaction list contains one row for that payment.

10.2 Signature verification

Scan Pay uses the existing Open API webhook signature. The platform uses the AppID (the existing API Key) from the primary account's webhook configuration as the HMAC key. It computes HMAC-SHA512 over the exact UTF-8 JSON request body and puts the 128-character lowercase hexadecimal digest in wh-signature. Partners can reuse their existing verification logic and credentials.

HTTP headerFormat
Content-Typeapplication/json
wh-signatureLowercase hexadecimal HMAC-SHA512 digest of the raw HTTP request body

Verify the signature using the raw HTTP request body bytes. Parsing the JSON and calling JSON.stringify again may change whitespace, field order, or escaping and invalidate the signature. Use the AppID string exactly as provided by the platform.

This Node.js example needs only built-in modules. Capture rawBody as a Buffer before your framework parses the JSON. Obtain appId from the primary account's webhook configuration for the current environment.

const { createHmac, timingSafeEqual } = require('node:crypto');

function verifyScanPayWebhook(rawBody, headers, appId) {
  const signature = headers['wh-signature'];
  if (!Buffer.isBuffer(rawBody) || typeof appId !== 'string' || !appId) return false;
  if (typeof signature !== 'string' || !/^[0-9a-f]{128}$/.test(signature)) return false;
  const expected = createHmac('sha512', appId).update(rawBody).digest();
  return timingSafeEqual(Buffer.from(signature, 'hex'), expected);
}

If one endpoint serves several API primary accounts, verify signatures using only the AppIDs configured for that endpoint. After verification, check that the payment belongs to the corresponding primary account and payer.

10.3 Receipt, deduplication, and retries

  1. Capture the raw body and validate the signature and event structure. Check event_identifier and match the payer and payment to your records.
  2. Within a local transaction, deduplicate by event_id and persist the event. Link refund events to the original payment using data.preTransactionId. Match payment events using data.id or data.callId.
  3. Return an HTTP 2xx response promptly after durable storage. Already persisted events should also receive a 2xx response. Process downstream business work asynchronously. Return a non-2xx response whenever you cannot reliably persist the event, so the platform retries.
  4. Events may arrive out of order. If an event is missing or appears out of order, or the reported status conflicts with your records, call GET /transactions/{id} and use the current payment details as the source of truth.

Each delivery attempt has a 5-second timeout and succeeds only on HTTP 2xx. The platform does not follow 3xx redirects. Failed deliveries are retried with exponential backoff and jitter. The base backoff interval is capped at one hour, and actual delivery times depend on scheduling. If another attempt fails once the event is at least 24 hours old, automatic retries stop. Use payment lookup and platform assistance when webhook delivery is delayed or retries are exhausted. Retry counts and intervals can vary.

Retries keep the same event_id and event payload.

11. Errors, rate limits and recovery

11.1 Common HTTP statuses

HTTP statusWhat to do
400Check request fields, KYC, supplementary information, the amount, the available balance and the payment limits. Use the business code to correct the request before retrying.
403Check the token, API permissions, IP allowlist, account and user status, and payer identity. For a payment lookup, check that the credential has scan_pay enabled on the order's API primary account.
404Check the resource ID, environment, and API primary account. For payment lookups, check whether the order belongs to the primary account or to a payer sub-account.
409Read the business code to distinguish an idempotency conflict, an unresolved request, an unusable quote or an unavailable route.
429Follow Retry-After and reduce the shared request rate for the payer, API credential and source IP.
5xx or timeoutTreat the outcome as unknown. Look up the original payment and retry the original request when appropriate.

11.2 Common business codes

An error can have a different HTTP status depending on where it occurs. Use the business code to guide recovery. For an unfamiliar code, keep the original request and order reference and contact the platform.

codeMeaningWhat to do
100001 or 999901 from an existing APIInvalid requestCheck the schema for types, UUIDs, length limits, amounts and allowed fields.
701009Insufficient API permissionsConfirm with the platform that Scan Pay is enabled for the specific API credential. Scan Pay returns HTTP 403 for this error.
100052Account frozenPause new payments, contact the platform and retain references to existing payments.
970001Unsupported QR codeStop processing this code and ask the user to verify the merchant QR code.
970002Scan Pay temporarily unavailableCheck whether the original operation or payment already exists before retrying.
970003Expired quote or session, already-used quote, or funding account changedIf you submitted a payment, look up the original order first. Once you confirm it was never accepted, request and confirm a new quote using the current funding source and QR mode.
970004Amount outside the limits of the QR codeCheck the amount and QR limits. For a dynamic QR code, use the amount returned by the decode.
970005KYC or supplementary information requiredRefresh the requirements and complete the listed action.
970006Channel order already in progress or processedLook up the original payment and keep its call ID.
970007 or 600004Pricing or exchange rate unavailableStop quoting this payment and contact the platform.
970008Scan Pay resource not foundCheck the environment, payer entity and resource UUID.
970009Call ID, preparation order or form version conflictLook up the original resource. A static QR preparation binds the amount and balance for the decode. For a form version conflict, refresh the requirements before submitting a new update.
970010Route or capability unavailableRead capabilities, pause the affected payment mode and contact the platform.
970011Payment validation failedCheck the current quote and account status, and request a new quote if needed.
970012Original operation still unresolvedKeep the original callId and request. Look up the original order and use the same call ID for any retry.
970014Payment limit exceededCheck the configured payment limits and stop this payment if it exceeds them.
970015Merchant payment failedRead fundsStatus and refundStatus to wait for compensation before requesting a new quote.
970016Conflicting evidence about the payment outcomeKeep the original order in manual_review, contact the platform and pause any replacement payment.
970017Multiple eligible CW balances and no balanceId supplied (HTTP 400)Call funding-sources, then select and submit a balanceId.
970018No eligible CW balance and no balanceId supplied (HTTP 400)Fund an eligible CW balance in the current funding account and request a new quote.

11.3 Scan Pay rate limits

All Scan Pay reads and writes share the following default limits.

ScopeDefault limit
Payer entity20 requests per minute
API customer configuration100 requests per minute
Source IP100 requests per minute

The limits apply across endpoints and may span the minute boundary. Concurrent payers share their API customer and IP limits. Queries, supplementary information, quotes and idempotent retries all count toward these limits.

Rate-limited responses include Retry-After in seconds and headers such as RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset. RateLimit-Reset is a relative number of seconds. Wait as directed, add jitter and avoid concurrent retries. Use Webhooks for payment updates and start any necessary polling at 5–10 second intervals with gradual backoff. Budget for the payer's other requests, cache capabilities briefly and use the time-range list for reconciliation.

11.4 Information to retain for recovery

For each business operation, keep the environment, partner user mapping, payer entity ID, operation callId, original request, resource UUIDs returned by the API, request and response times, and any available requestId. Keep a traceable record of each user confirmation. Restrict access to credentials, QR data and KYC information and keep them out of logs.

A payment in progress retains its funding source, merchant amount and route. Revoked limits, disabled permissions or a local timeout leave the channel result unresolved. Determine the original order's outcome before allowing a new payment.

12. Integration testing and publication

12.1 Partner acceptance checklist

ScenarioExpected result
Token, IP and permissionsValid credentials work. The platform rejects invalid or expired tokens, credentials without Scan Pay permission and requests from IP addresses outside the allowlist. The integration distinguishes the reasons.
Payer identity and order ownershipDecoding requires the payer entity header. Later requests inherit the payer from the session. Payment lookups check the API primary account and the account that owns the order. The selected balance belongs to the funding account.
Crypto wallet debitsBoth modes list and accept only CW balances for new payments. Previously accepted orders remain queryable and use their original balance for compensation.
Automatic balance selectionA request can omit balanceId when one balance qualifies, must specify it when multiple qualify, and is rejected when none qualify. Retrying a quote retains the original balance, and payment refers to the original quoteId.
Switching funding modeThe main account can fund its payers centrally, and white-label subaccounts can fund their own balances. Existing quotes need fresh confirmation after re-quoting. Previously accepted orders keep their original ownership and use the original debit account for compensation.
KYC and account statusThe platform rejects new payments from an identity that has incomplete KYC or is frozen, inactive or disabled. The user interface directs the user to verification or platform support.
Wallet and balance identifiersThe address request uses a wallet ID, and the quote uses a balance ID. After funding, check the balance again in funding-sources.
Capability checksThe integration offers supported countries, currencies and QR modes. It requests static quotes only when capabilities include static and specify channel_prepare.
Static channel preparationAt most one preparation is created per decode. After a timeout, reuse the original quote callId. Payment reuses the prepared channel order.
Preparation exceptionsThe platform isolates a preparation reported as already paid or in execution. An abandoned or expired preparation stays distinct from a successful payment. Keep resolving the original preparation when its outcome is unknown.
Dynamic QR integrityAttempts to change the merchant amount, currency, payer or balance fail against the existing quote.
Supplementary informationHandle ready, action_required and blocked. The platform rejects unknown fields, invalid options and stale form versions.
User confirmationShow the complete quote. Request a fresh quote and ask the user to confirm again if it changes or expires.
Idempotency and timeoutsRepeating an identical request returns the original payment. Changing the request under the same call ID is a conflict. After a timeout, look up the original order first and avoid a duplicate payment.
Asynchronous resultsHTTP 201 with processing displays as in progress. Show success once the status is completed, and pause replacement payments during manual_review.
Failure compensationWait while status=failed and fundsStatus=compensation_pending. Request a new quote and confirmation only after the order is compensated (refundStatus=completed).
Queries and paginationRetrieve the original order by UUID or exact callId in the original account scope. A creation time range spans at most 31 days. Parse list, total and current correctly.
Webhook verificationVerify wh-signature using the raw body and the AppID from the primary account's webhook configuration. Reject an incorrect AppID, a modified body or a missing signature. Duplicate and out-of-order events must not apply a state change twice.
Webhook delivery failuresReturn a non-2xx response if you cannot persist the event. Accept redelivery after recovery. Use queries and reconciliation to recover missed notifications.
Rate limitingHonor Retry-After and recover gracefully as concurrent users share the API customer and IP limits.

Did this page help you?