Create Payment Order#
Create a pending order and get a checkout URL for the buyer.
/api/v6/pay/onchainos-payment/createThe endpoint sets the recipient address and token amount when you create the order. Checkout validates the payment against those order details.
Request Parameters#
| Field | Type | Required | Description |
|---|---|---|---|
merchantPaymentId | String | Yes | A nonempty merchant order ID of up to 64 characters. It must be unique for the API key. |
to | String | Yes | Merchant recipient address. Use an EVM address with 0x followed by 40 hexadecimal characters. The zero address is invalid. |
fiatAmount | String | Yes | Positive reference fiat amount with up to 9 digits before the decimal point and 2 after it, for example "10.00". |
fiatCurrency | String | Yes | Reference fiat currency of 3 to 10 letters, for example "USD". |
quotes | Array | Yes | An array containing exactly one payment quote. |
returnUrl | String | No | Browser 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. |
merchantDisplayName | String | No | Merchant display name of up to 128 characters. |
productDesc | String | No | Product name or description of up to 256 characters. |
expireSeconds | Integer | No | Order lifetime in seconds, from 1 to 1800. Defaults to 1800. |
quotes[]
| Field | Type | Required | Description |
|---|---|---|---|
paymentToken | Object | Yes | Token and amount for this order. |
quotes[].paymentToken
| Field | Type | Required | Description |
|---|---|---|---|
chainId | String | Yes | Set to "196". |
tokenAddress | String | Yes | Contract address of a supported token. |
tokenAmount | String | Yes | A 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. tokenAmountuses the token's smallest unit. For a token with 6 decimals,"10000000"represents 10 tokens.fiatAmountandfiatCurrencyare 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.
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.
| Field | Type | Description |
|---|---|---|
merchantPaymentId | String | Merchant order ID. |
paymentIntentId | String | Platform payment order ID. Store it and send it back as the original string. Treat it as an opaque value. |
status | String | Order status. A newly created order is pending. |
to | String | Recipient address normalized to lowercase. |
quotes | Array | Array containing one payment quote with token details filled in by the server. |
checkoutUrl | String | Checkout URL where the buyer pays. |
expiresAt | String | Order 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.
{
"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.
