Ontwikkelaarsportaal

Create Payment Order#

Create a pending order and get a checkout URL for the buyer.

POST
/api/v6/pay/onchainos-payment/create

The endpoint sets the recipient address and token amount when you create the order. Checkout validates the payment against those order details.

Request Parameters#

FieldTypeRequiredDescription
merchantPaymentIdStringYesA nonempty merchant order ID of up to 64 characters. It must be unique for the API key.
toStringYesMerchant recipient address. Use an EVM address with 0x followed by 40 hexadecimal characters. The zero address is invalid.
fiatAmountStringYesPositive reference fiat amount with up to 9 digits before the decimal point and 2 after it, for example "10.00".
fiatCurrencyStringYesReference fiat currency of 3 to 10 letters, for example "USD".
quotesArrayYesAn array containing exactly one payment quote.
returnUrlStringNoBrowser return URL of up to 256 characters. Use it to send the buyer back to your site. Query the order from your server for the payment result.
merchantDisplayNameStringNoMerchant display name of up to 128 characters.
productDescStringNoProduct name or description of up to 256 characters.
expireSecondsIntegerNoOrder lifetime in seconds, from 1 to 1800. Defaults to 1800.

quotes[]

FieldTypeRequiredDescription
paymentTokenObjectYesToken and amount for this order.

quotes[].paymentToken

FieldTypeRequiredDescription
chainIdStringYesSet to "196".
tokenAddressStringYesContract address of a supported token.
tokenAmountStringYesA positive integer string in the token's smallest unit, from "10000" to the maximum uint256 value.

The server populates tokenSymbol and tokenDecimal. Omit them from the request.

Amounts#

  • The buyer pays and the merchant receives the amount in quotes[0].paymentToken.tokenAmount.
  • tokenAmount uses the token's smallest unit. For a token with 6 decimals, "10000000" represents 10 tokens.
  • fiatAmount and fiatCurrency are reference values. Checkout charges the specified token amount directly.
  • The minimum order amount is 0.01.

to is the final recipient address. Check it before creating the order. Checkout uses the recipient and amount from the order.

Request Example#

This example creates a 10 USDC order. Replace the sample recipient address with your own.

bash
curl --request POST 'https://web3.okx.com/api/v6/pay/onchainos-payment/create' \
  --header "OK-ACCESS-KEY: ${OK_ACCESS_KEY}" \
  --header "OK-ACCESS-SIGN: ${OK_ACCESS_SIGN}" \
  --header "OK-ACCESS-PASSPHRASE: ${OK_ACCESS_PASSPHRASE}" \
  --header "OK-ACCESS-TIMESTAMP: ${OK_ACCESS_TIMESTAMP}" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "merchantPaymentId": "order_20261106_0001",
    "to": "0x1111111111111111111111111111111111111111",
    "fiatAmount": "10.00",
    "fiatCurrency": "USD",
    "quotes": [
      {
        "paymentToken": {
          "chainId": "196",
          "tokenAddress": "0xb6ceceab302e2e4948951ee7843fc24e92933061",
          "tokenAmount": "10000000"
        }
      }
    ],
    "merchantDisplayName": "Example Store",
    "productDesc": "Example product",
    "returnUrl": "https://merchant.example.com/payment/result",
    "expireSeconds": 1800
  }'

Response Parameters#

The response includes these fields in data.

FieldTypeDescription
merchantPaymentIdStringMerchant order ID.
paymentIntentIdStringPlatform payment order ID. Store it and send it back as the original string. Treat it as an opaque value.
statusStringOrder status. A newly created order is pending.
toStringRecipient address normalized to lowercase.
quotesArrayArray containing one payment quote with token details filled in by the server.
checkoutUrlStringCheckout URL where the buyer pays.
expiresAtStringOrder expiration in ISO 8601 UTC format, ending in Z.

quotes[].paymentToken also returns tokenSymbol (String) and tokenDecimal (Integer).

Response Example#

The domain and path in checkoutUrl are examples. Redirect the buyer to the full URL returned by the API.

json
{
  "code": 0,
  "msg": "",
  "data": {
    "merchantPaymentId": "order_20261106_0001",
    "paymentIntentId": "2026110600000123456789012345678901",
    "status": "pending",
    "to": "0x1111111111111111111111111111111111111111",
    "quotes": [
      {
        "paymentToken": {
          "chainId": "196",
          "tokenSymbol": "USDC",
          "tokenAddress": "0xb6ceceab302e2e4948951ee7843fc24e92933061",
          "tokenDecimal": 6,
          "tokenAmount": "10000000"
        },
        "exchangeRate": "1"
      }
    ],
    "checkoutUrl": "https://checkout.example.com/pay?paymentIntentId=2026110600000123456789012345678901",
    "expiresAt": "2026-11-06T04:30:00Z"
  }
}

Duplicate Requests and Timeouts#

Reusing a merchantPaymentId with the same API key returns 61009. Query the order separately to retrieve it.

If the create request times out or the connection drops, call the query endpoint with the original merchantPaymentId to check whether the order was created. If the order exists, continue with it. Query first to avoid creating a duplicate business order. Use a new merchant order ID if you need to create another order after expiration.