onchain-pay-open-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBinance Onchain-Pay Open API Skill
Binance Onchain-Pay 开放API Skill
Call Binance Onchain-Pay Open API endpoints with automatic RSA SHA256 request signing.
调用 Binance Onchain-Pay 开放API接口,自动完成 RSA SHA256 请求签名。
Use Cases & Scenarios
使用场景
This skill is designed for the following scenarios:
该 Skill 适用于以下场景:
1. 💳 Fiat-to-Crypto Purchase & Send
1. 💳 法币兑加密货币购买并发送
When to use: User wants to buy crypto with fiat currency and send directly to an external on-chain wallet address
- Buy USDT with USD/EUR/TWD using credit card → Send to MetaMask address on BSC
- Purchase BTC with Google Pay → Transfer to hardware wallet
- Buy USDC with P2P → Send to DeFi protocol contract address
Key APIs: → → →
trading-pairspayment-method-listestimated-quotepre-order适用场景:用户希望用法币购买加密货币并直接发送到外部链上钱包地址
- 使用信用卡以 USD/EUR/TWD 购买 USDT → 发送到 BSC 链上的 MetaMask 地址
- 使用 Google Pay 购买 BTC → 转账到硬件钱包
- 通过 P2P 购买 USDC → 发送到 DeFi 协议合约地址
核心API: → → →
trading-pairspayment-method-listestimated-quotepre-order2. 🔄 Direct Crypto Transfer (Send Primary)
2. 🔄 加密货币直接转账(发送优先)
When to use: User has crypto in Binance account and wants to send to external address
- Send existing USDT from Binance Spot to friend's wallet address
- Transfer ETH to Uniswap contract for trading
- Move crypto from Binance to self-custodial wallet (Trust Wallet, Ledger, etc.)
Key APIs: with customization
pre-orderSEND_PRIMARY适用场景:用户 Binance 账户中持有加密货币,想要发送到外部地址
- 将 Binance 现货账户中已有的 USDT 发送到朋友的钱包地址
- 转账 ETH 到 Uniswap 合约进行交易
- 将加密货币从 Binance 转移到自托管钱包(Trust Wallet、Ledger等)
核心API:配置 参数的 接口
SEND_PRIMARYpre-order3. 🔗 Cross-Chain Bridge Operations
3. 🔗 跨链桥操作
When to use: User needs to buy crypto on one chain and transfer to another network
- Buy USDC on Ethereum → Bridge to Polygon for lower fees
- Purchase tokens on BSC → Transfer to Base network
- Fiat to crypto on Solana → Send to Arbitrum for DeFi
Key APIs: → with network selection
crypto-networkpre-order适用场景:用户需要在某条链上购买加密货币,再转账到另一个网络
- 在以太坊链上购买 USDC → 跨桥到 Polygon 以降低手续费
- 在 BSC 链上购买代币 → 转账到 Base 网络
- 用法币在 Solana 链上购买加密货币 → 发送到 Arbitrum 用于 DeFi 操作
核心API: → 配置网络选择的 接口
crypto-networkpre-order4. 🏪 Merchant Payment Integration
4. 🏪 商户支付集成
When to use: Integrate crypto payment gateway for e-commerce or services
- Accept fiat payments and auto-convert to crypto
- Enable "Pay with Crypto" checkout flow
- Process subscription payments with crypto
Key APIs: with tracking
pre-orderexternalOrderId适用场景:为电商或服务类场景集成加密货币支付网关
- 接受法币支付并自动转换为加密货币
- 支持「加密货币支付」的结算流程
- 处理加密货币订阅付款
核心API:配置 跟踪的 接口
externalOrderIdpre-order5. 🤖 Smart Contract Interaction (Onchain-Pay Easy)
5. 🤖 智能合约交互(Onchain-Pay 便捷模式)
When to use: Buy crypto and execute smart contract in one transaction
- Buy USDT and deposit to lending protocol
- Purchase tokens and stake in DeFi pool
- Fiat on-ramp directly to GameFi or NFT marketplace
Key APIs: with customization
pre-orderON_CHAIN_PROXY_MODE适用场景:购买加密货币并在单交易中执行智能合约
- 购买 USDT 并存入借贷协议
- 购买代币并质押到 DeFi 矿池
- 法币入金直接到 GameFi 或 NFT 市场
核心API:配置 参数的 接口
ON_CHAIN_PROXY_MODEpre-order6. 📊 Query & Monitoring
6. 📊 查询与监控
When to use: Check order status, available networks, or payment methods
- Monitor order processing status (pending, completed, failed)
- List supported fiat currencies and cryptocurrencies
- Check available payment methods for specific country/amount
- Verify network fees and limits
Key APIs: , , ,
ordercrypto-networktrading-pairspayment-method-list适用场景:查看订单状态、可用网络或支付方式
- 监控订单处理状态(待处理、已完成、失败)
- 列出支持的法币和加密货币币种
- 查询特定国家/金额可用的支付方式
- 核验网络手续费和限额
核心API:、、、
ordercrypto-networktrading-pairspayment-method-listQuick Reference
快速参考
| Endpoint | API Path | Required Params | Optional Params |
|---|---|---|---|
| Payment Method List (v1) | | fiatCurrency, cryptoCurrency, totalAmount, amountType | network, contractAddress |
| Payment Method List (v2) | | (none) | lang |
| Trading Pairs | | (none) | (none) |
| Estimated Quote | | fiatCurrency, requestedAmount, payMethodCode, amountType | cryptoCurrency, contractAddress, address, network |
| Pre-order | | externalOrderId, merchantCode, merchantName, ts | fiatCurrency, fiatAmount, cryptoCurrency, requestedAmount, amountType, address, network, payMethodCode, payMethodSubCode, redirectUrl, failRedirectUrl, redirectDeepLink, failRedirectDeepLink, customization, destContractAddress, destContractABI, destContractParams, affiliateCode, gtrTemplateCode, contractAddress |
| Get Order | | externalOrderId | (none) |
| Crypto Network | | (none) | (none) |
| P2P Trading Pairs | | (none) | fiatCurrency |
| Endpoint | API Path | Required Params | Optional Params |
|---|---|---|---|
| 支付方式列表(v1) | | fiatCurrency, cryptoCurrency, totalAmount, amountType | network, contractAddress |
| 支付方式列表(v2) | | 无 | lang |
| 交易对列表 | | 无 | 无 |
| 预估报价 | | fiatCurrency, requestedAmount, payMethodCode, amountType | cryptoCurrency, contractAddress, address, network |
| 预下单 | | externalOrderId, merchantCode, merchantName, ts | fiatCurrency, fiatAmount, cryptoCurrency, requestedAmount, amountType, address, network, payMethodCode, payMethodSubCode, redirectUrl, failRedirectUrl, redirectDeepLink, failRedirectDeepLink, customization, destContractAddress, destContractABI, destContractParams, affiliateCode, gtrTemplateCode, contractAddress |
| 订单查询 | | externalOrderId | 无 |
| 加密货币网络列表 | | 无 | 无 |
| P2P交易对列表 | | 无 | fiatCurrency |
How to Execute a Request
如何执行请求
Step 1: Gather credentials
步骤1:获取凭证
Use the default account (prod) unless the user specifies otherwise. You need:
- BASE_URL: API base URL
- CLIENT_ID: Client identifier
- API_KEY: The sign access token
- PEM_PATH: Absolute path to the RSA private key PEM file
Use the account marked in .
(default).local.md除非用户指定其他账户,否则使用默认账户(prod)。你需要:
- BASE_URL:API基础地址
- CLIENT_ID:客户端标识
- API_KEY:签名访问令牌
- PEM_PATH:RSA私钥PEM文件的绝对路径
使用 中标记为 的账户。
.local.md(default)Step 2: Build the JSON body
步骤2:构建JSON请求体
Build a compact JSON body from user-specified parameters. Remove any parameters the user did not provide.
IMPORTANT: Address and Network Validation
- (destination wallet address) and
address(blockchain network) are REQUIRED for all pre-order requestsnetwork - If the user has configured and
Default AddressinDefault Network, use them automatically.local.md - If not configured or not provided by user, ASK the user to provide both values before proceeding
根据用户指定的参数构建精简的JSON请求体,移除所有用户未提供的参数。
重要提示:地址和网络校验
- 所有预下单请求都必须提供 (目标钱包地址)和
address(区块链网络)参数network - 如果用户已经在 中配置了「默认地址」和「默认网络」,则自动使用这两个值
.local.md - 如果没有配置或用户未提供这两个值,在继续操作前请先询问用户获取
Step 3: Sign and call using the bundled script
步骤3:使用内置脚本签名并调用
bash
bash <skill_path>/scripts/sign_and_call.sh \
"<BASE_URL>" \
"<API_PATH>" \
"<CLIENT_ID>" \
"<API_KEY>" \
"<PEM_PATH>" \
'<JSON_BODY>'bash
bash <skill_path>/scripts/sign_and_call.sh \
"<BASE_URL>" \
"<API_PATH>" \
"<CLIENT_ID>" \
"<API_KEY>" \
"<PEM_PATH>" \
'<JSON_BODY>'Step 4: Return results
步骤4:返回结果
Display the JSON response to the user in a readable format.
将JSON响应以易读的格式展示给用户。
Authentication
鉴权说明
See for full signing details.
references/authentication.mdSummary:
- Payload = +
JSON_BODY(milliseconds)TIMESTAMP - Sign payload with RSA SHA256 using PEM private key
- Base64 encode the signature (single line)
- Send as POST with headers: ,
X-Tesla-ClientId,X-Tesla-SignAccessToken,X-Tesla-Signature,X-Tesla-TimestampContent-Type: application/json
完整的签名细节请查看 。
references/authentication.md摘要说明:
- 签名载荷 = +
JSON_BODY(毫秒级时间戳)TIMESTAMP - 使用PEM私钥通过RSA SHA256算法对载荷签名
- 对签名结果做Base64编码(单行格式)
- 发送POST请求,携带以下请求头:、
X-Tesla-ClientId、X-Tesla-SignAccessToken、X-Tesla-Signature、X-Tesla-TimestampContent-Type: application/json
Parameters Reference
参数参考
Payment Method List v1 (buy/payment-method-list
)
buy/payment-method-list支付方式列表v1(buy/payment-method-list
)
buy/payment-method-list| Parameter | Type | Required | Description |
|---|---|---|---|
| fiatCurrency | string | Yes | Fiat currency code (e.g., |
| cryptoCurrency | string | Yes | Crypto currency code (e.g., |
| totalAmount | number | Yes | Amount value |
| amountType | number | Yes | |
| network | string | No | Blockchain network (e.g., |
| contractAddress | string | No | Token contract address (required for non-native tokens) |
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| fiatCurrency | string | 是 | 法币币种编码(如 |
| cryptoCurrency | string | 是 | 加密货币币种编码(如 |
| totalAmount | number | 是 | 金额数值 |
| amountType | number | 是 | |
| network | string | 否 | 区块链网络(如 |
| contractAddress | string | 否 | 代币合约地址(非原生代币必填) |
Payment Method List v2 (v2/buy/payment-method-list
)
v2/buy/payment-method-list支付方式列表v2(v2/buy/payment-method-list
)
v2/buy/payment-method-listGet all available payment methods without specifying fiat/crypto parameters. Simplified version of v1.
| Parameter | Type | Required | Description |
|---|---|---|---|
| lang | string | No | Language code for localized payment method names (e.g., |
Differences from v1:
- Simpler: No need to specify fiatCurrency, cryptoCurrency, or amount
- Comprehensive: Returns all available payment methods for the merchant
- Use case: Useful for displaying all options before user input
Response Format: Same as v1, returns list of payment methods with their limits and properties.
无需指定法币/加密货币参数即可获取所有可用支付方式,是v1的简化版本。
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| lang | string | 否 | 支付方式名称本地化的语言编码(如 |
与v1的差异:
- 更简单:无需指定法币币种、加密货币币种或金额
- 更全面:返回商户可用的所有支付方式
- 适用场景:适合在用户输入前展示所有可选支付方式
响应格式:与v1一致,返回支付方式列表及对应限额和属性。
Estimated Quote (buy/estimated-quote
)
buy/estimated-quote预估报价(buy/estimated-quote
)
buy/estimated-quote| Parameter | Type | Required | Description |
|---|---|---|---|
| fiatCurrency | string | Yes | Fiat currency code |
| cryptoCurrency | string | No | Crypto currency code (optional if contractAddress provided) |
| requestedAmount | number | Yes | Amount value |
| payMethodCode | string | Yes | Payment method (e.g., |
| amountType | number | Yes | |
| network | string | Yes* | Blockchain network (can use default from |
| contractAddress | string | No | Token contract address |
| address | string | Yes* | Destination wallet address for receiving crypto |
* Recommended: These parameters should be provided. If not specified by user, check for defaults. If no defaults exist, ask user before proceeding.
.local.md| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| fiatCurrency | string | 是 | 法币币种编码 |
| cryptoCurrency | string | 否 | 加密货币币种编码(如果提供了contractAddress则可选) |
| requestedAmount | number | 是 | 金额数值 |
| payMethodCode | string | 是 | 支付方式(如 |
| amountType | number | 是 | |
| network | string | 是* | 区块链网络(可使用 |
| contractAddress | string | 否 | 代币合约地址 |
| address | string | 是* | 接收加密货币的目标钱包地址 |
* 推荐提供这些参数。如果用户未指定,请检查 中的默认值。如果没有默认值,请在继续操作前询问用户。
.local.mdPre-order (buy/pre-order
)
buy/pre-order预下单(buy/pre-order
)
buy/pre-orderCreate a buy pre-order and return the redirect link for payment.
| Parameter | Type | Required | Description |
|---|---|---|---|
| externalOrderId | string | Yes | Partner's unique order ID (must be unique) |
| merchantCode | string | Yes | Merchant code (e.g., |
| merchantName | string | Yes | Merchant display name (e.g., |
| ts | number | Yes | Current timestamp in milliseconds |
| fiatCurrency | string | No* | Fiat currency code (e.g., |
| fiatAmount | number | No* | Fiat amount to spend |
| cryptoCurrency | string | No* | Crypto currency to buy (e.g., |
| requestedAmount | number | No* | Amount value (fiat or crypto based on amountType) |
| amountType | number | No* | |
| address | string | No | Destination wallet address for receiving crypto |
| network | string | No | Blockchain network (e.g., |
| payMethodCode | string | No | Payment method code (e.g., |
| payMethodSubCode | string | No | Payment method sub-code (e.g., |
| redirectUrl | string | No | Success redirect URL |
| failRedirectUrl | string | No | Failure redirect URL |
| redirectDeepLink | string | No | Deep link for success (mobile apps) |
| failRedirectDeepLink | string | No | Deep link for failure (mobile apps) |
| customization | object | No | Custom configuration object (see Customization section below) |
| destContractAddress | string | No | Destination contract address (for Onchain-Pay Easy mode) |
| destContractABI | string | No | Contract ABI name (for Onchain-Pay Easy mode) |
| destContractParams | object | No | Contract parameters (for Onchain-Pay Easy mode) |
| affiliateCode | string | No | Affiliate code for commission tracking |
| gtrTemplateCode | string | No | GTR template code (e.g., |
| contractAddress | string | No | Token contract address (for non-native tokens) |
* Either or ( + ) should be provided. If is not provided, the system will auto-select available fiat currencies.
fiatAmountrequestedAmountamountTypefiatCurrencyResponse Example:
json
{
"code": "000000",
"message": "success",
"data": {
"link": "https://app.binance.com/uni-qr/ccnt?...",
"linkExpireTime": 1772852565045
},
"success": true
}创建购买预订单并返回支付跳转链接。
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| externalOrderId | string | 是 | 合作方唯一订单ID(必须唯一) |
| merchantCode | string | 是 | 商户编码(如 |
| merchantName | string | 是 | 商户展示名称(如 |
| ts | number | 是 | 当前毫秒级时间戳 |
| fiatCurrency | string | 否* | 法币币种编码(如 |
| fiatAmount | number | 否* | 消费的法币金额 |
| cryptoCurrency | string | 否* | 要购买的加密货币(如 |
| requestedAmount | number | 否* | 金额数值(根据amountType决定是法币还是加密货币金额) |
| amountType | number | 否* | |
| address | string | 否 | 接收加密货币的目标钱包地址 |
| network | string | 否 | 区块链网络(如 |
| payMethodCode | string | 否 | 支付方式编码(如 |
| payMethodSubCode | string | 否 | 支付方式子编码(如 |
| redirectUrl | string | 否 | 成功跳转地址 |
| failRedirectUrl | string | 否 | 失败跳转地址 |
| redirectDeepLink | string | 否 | 成功跳转Deep Link(移动端应用使用) |
| failRedirectDeepLink | string | 否 | 失败跳转Deep Link(移动端应用使用) |
| customization | object | 否 | 自定义配置对象(参考下方自定义配置章节) |
| destContractAddress | string | 否 | 目标合约地址(Onchain-Pay便捷模式使用) |
| destContractABI | string | 否 | 合约ABI名称(Onchain-Pay便捷模式使用) |
| destContractParams | object | 否 | 合约参数(Onchain-Pay便捷模式使用) |
| affiliateCode | string | 否 | 用于佣金跟踪的推广码 |
| gtrTemplateCode | string | 否 | GTR模板编码(如 |
| contractAddress | string | 否 | 代币合约地址(非原生代币使用) |
* 需要提供 或者( + )两者其一。如果未提供 ,系统会自动选择可用的法币币种。
fiatAmountrequestedAmountamountTypefiatCurrency响应示例:
json
{
"code": "000000",
"message": "success",
"data": {
"link": "https://app.binance.com/uni-qr/ccnt?...",
"linkExpireTime": 1772852565045
},
"success": true
}Get Order (order
)
order订单查询(order
)
order| Parameter | Type | Required | Description |
|---|---|---|---|
| externalOrderId | string | Yes | The external order ID to query |
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| externalOrderId | string | 是 | 要查询的外部订单ID |
Customization Options
自定义配置选项
The field in pre-order API accepts various flags to customize the buy flow behavior. Each merchant must have the corresponding permission configured in table.
customizationdb.merchant_info预下单API中的字段支持多种配置标记,可自定义购买流程行为。每个商户需要在表中配置对应的权限才能使用。
customizationdb.merchant_infoAvailable Customization Flags
可用自定义配置标记
| Flag | Code | Type | Availability | Description | Use Case |
|---|---|---|---|---|---|
| 1 | array | Open API ✓ | Lock specific order attributes so users cannot modify them. Values: | Fixed-parameter orders |
| 2 | boolean | Open API ✓ | Skip the cashier page and proceed directly to payment. Reduces user friction in the checkout flow. | Streamlined payment experience |
| 3 | boolean | Open API ✓ | Automatically redirect to | Seamless user experience |
| 6 | boolean | Open API ✓ | Hide the "Send" tab in the UI. Useful when only buy flow is needed. | Buy-only integration |
| 7 | boolean | Open API ✓ | Enable Send Crypto feature. If user's Binance balance is insufficient, auto-trigger buy flow first. | Send crypto to external address |
| 8 | string | Open API ✓ | Override the display name shown to users in the UI. | Custom branding |
| 9 | boolean | Open API ✓ | User receives net amount after deducting all fees. Total cost is more transparent. | Better UX for showing final received amount |
| 10 | boolean | Open API ✓ | Enable P2P Express mode for faster P2P order matching. | Quick P2P transactions |
| 11 | boolean | Web3 only | Allow users to select different networks. Default is locked to pre-selected network. Note: Currently only available for Web3 entrance, not available for Open API. | Multi-network support (Web3 only) |
| 12 | boolean | Open API ✓ | Enable Onchain-Pay Easy mode. After buying crypto, Onchain-Pay will execute smart contract interaction instead of direct withdrawal to user wallet. Requires | Fiat to Smart Contract integration |
| 13 | boolean | Open API ✓ | Flexible Send Primary mode with more options. | Advanced send crypto scenarios |
| 标记名 | 编码 | 类型 | 可用性 | 描述 | 适用场景 |
|---|---|---|---|---|---|
| 1 | array | 开放API ✓ | 锁定指定订单属性,用户无法修改。可选值: | 固定参数订单 |
| 2 | boolean | 开放API ✓ | 跳过收银台页面直接进入支付环节,降低结算流程的用户摩擦 | 简化支付体验 |
| 3 | boolean | 开放API ✓ | 订单完成后自动跳转到 | 无缝用户体验 |
| 6 | boolean | 开放API ✓ | 隐藏界面中的「发送」标签,适合仅需要购买流程的场景 | 仅购买功能集成 |
| 7 | boolean | 开放API ✓ | 启用加密货币发送功能。如果用户Binance余额不足,会自动先触发购买流程 | 发送加密货币到外部地址 |
| 8 | string | 开放API ✓ | 覆盖界面中展示给用户的商户名称 | 自定义品牌展示 |
| 9 | boolean | 开放API ✓ | 用户收到扣除所有手续费后的净额,总花费更透明 | 优化展示最终到账金额的用户体验 |
| 10 | boolean | 开放API ✓ | 启用P2P快捷模式,加快P2P订单匹配速度 | 快速P2P交易 |
| 11 | boolean | 仅Web3可用 | 允许用户选择不同网络,默认锁定为预选择的网络。注意:目前仅支持Web3入口,开放API不可用 | 多网络支持(仅Web3) |
| 12 | boolean | 开放API ✓ | 启用Onchain-Pay便捷模式。购买加密货币后,Onchain-Pay会执行智能合约交互,而非直接提现到用户钱包。需要搭配 | 法币到智能合约集成 |
| 13 | boolean | 开放API ✓ | 灵活的发送优先模式,支持更多配置选项 | 高级加密货币发送场景 |
Customization Examples
自定义配置示例
Example 1: Basic Card Payment
json
{
"customization": {}
}Example 2: Onchain-Pay Easy (On-Chain Proxy)
json
{
"customization": {
"ON_CHAIN_PROXY_MODE": true,
"NET_RECEIVE": true,
"SEND_PRIMARY": true
},
"destContractAddress": "0x128...974",
"destContractABI": "depositFor",
"destContractParams": {
"accountType": 2
}
}Example 3: Send Crypto
json
{
"customization": {
"SEND_PRIMARY_FLEXIBLE": true,
"SEND_PRIMARY": true
}
}Example 4: P2P with Auto Redirection
json
{
"customization": {
"AUTO_REDIRECTION": true,
"P2P_EXPRESS": true
}
}Example 5: Lock Order Attributes
json
{
"customization": {
"LOCK_ORDER_ATTRIBUTES": [2, 3, 6, 7, 8],
"MERCHANT_DISPLAY_NAME": "My Custom Brand"
}
}Lock attribute codes:
- = Crypto currency
2 - = Amount
3 - = Address
6 - = Fiat amount
7 - = Crypto amount
8
Example 6: Net Receive Mode
json
{
"customization": {
"NET_RECEIVE": true,
"SEND_PRIMARY": true
}
}Example 7: Hide Send Tab
json
{
"customization": {
"HIDE_SEND": true
}
}Example 8: Skip Cashier (Direct Payment)
json
{
"customization": {
"SKIP_CASHIER": true
}
}示例1:基础银行卡支付
json
{
"customization": {}
}示例2:Onchain-Pay便捷模式(链上代理)
json
{
"customization": {
"ON_CHAIN_PROXY_MODE": true,
"NET_RECEIVE": true,
"SEND_PRIMARY": true
},
"destContractAddress": "0x128...974",
"destContractABI": "depositFor",
"destContractParams": {
"accountType": 2
}
}示例3:加密货币发送
json
{
"customization": {
"SEND_PRIMARY_FLEXIBLE": true,
"SEND_PRIMARY": true
}
}示例4:带自动跳转的P2P支付
json
{
"customization": {
"AUTO_REDIRECTION": true,
"P2P_EXPRESS": true
}
}示例5:锁定订单属性
json
{
"customization": {
"LOCK_ORDER_ATTRIBUTES": [2, 3, 6, 7, 8],
"MERCHANT_DISPLAY_NAME": "My Custom Brand"
}
}锁定属性编码说明:
- = 加密货币币种
2 - = 金额
3 - = 地址
6 - = 法币金额
7 - = 加密货币金额
8
示例6:净额到账模式
json
{
"customization": {
"NET_RECEIVE": true,
"SEND_PRIMARY": true
}
}示例7:隐藏发送标签
json
{
"customization": {
"HIDE_SEND": true
}
}示例8:跳过收银台(直接支付)
json
{
"customization": {
"SKIP_CASHIER": true
}
}Important Notes
重要注意事项
- Permission Required: Each customization flag requires merchant permission. Check with admin if a flag is not working.
- Onchain-Pay Easy: Only supported on BSC network currently. Requires contract integration.
- Validation: Invalid customization values (e.g., for
null) will returnMERCHANT_DISPLAY_NAMEerror.ILLEGAL_CUSTOMIZATION_VALUE - Combinations: Some flags work together (e.g., +
NET_RECEIVE), while others are independent.SEND_PRIMARY - Testing: Use test accounts () for testing customization flags before production.
connect-gray - Internal Flags: (code 4) and
OPERATION(code 5) are internal use only and should NOT be passed from merchant side.SKIP_WITHDRAW - OPEN_NETWORK: Currently only available for Web3 entrance, not available for Open API. Do not use this flag in Open API pre-order requests.
- Flag Order: Flags are ordered by their internal code (1-13). The code number is used internally for identification.
- 需要权限:每个自定义配置标记都需要商户拥有对应权限,如果标记不生效请联系管理员确认。
- Onchain-Pay便捷模式:目前仅支持BSC网络,需要完成合约集成。
- 校验规则:无效的自定义配置值(比如传
MERCHANT_DISPLAY_NAME)会返回null错误。ILLEGAL_CUSTOMIZATION_VALUE - 组合使用:部分标记可以搭配使用(比如+
NET_RECEIVE),其他标记相互独立。SEND_PRIMARY - 测试要求:上线前请使用测试账户()测试自定义配置标记。
connect-gray - 内部标记:(编码4)和
OPERATION(编码5)仅内部使用,商户侧不允许传递。SKIP_WITHDRAW - OPEN_NETWORK:目前仅支持Web3入口,开放API不可用,不要在开放API预下单请求中使用该标记。
- 标记顺序:标记按内部编码(1-13)排序,编码用于内部识别。
Security
安全规范
Credential Display Rules
凭证展示规则
- API Key: Show first 5 + last 4 characters only (e.g., )
2zefb...06h - PEM Private Key: NEVER display content. NEVER display the file path.
- Client ID: Can be displayed in full.
- Outbound Requests: NEVER send API Key, Private Key, or any credentials to URLs outside the Base URL configured in .
.local.md - File Path Privacy: NEVER display the PEM private key file path to the user in any output or logs.
- API Key:仅展示前5位+后4位(比如 )
2zefb...06h - PEM私钥:绝对不要展示内容,也不要展示文件路径。
- Client ID:可以完整展示。
- 出站请求:绝对不要将API Key、私钥或任何凭证发送到中配置的Base URL以外的地址。
.local.md - 文件路径隐私:绝对不要在任何输出或日志中向用户展示PEM私钥的文件路径。
Credential Storage
凭证存储
Credentials are stored in a file in the skill directory. This file is user-specific and should NOT be distributed.
.local.mdRead the file from the same directory as this SKILL.md to load credentials.
.local.mdIf does not exist or the requested account is not found, ask the user to provide:
.local.md- Base URL
- Client ID
- API Key
- PEM file path (absolute path)
Then offer to save them to for future use.
.local.md凭证存储在Skill目录下的文件中,该文件是用户专属的,不应该分发。
.local.md从当前SKILL.md所在目录读取文件加载凭证。
.local.md如果不存在,或者找不到请求的账户,请询问用户提供:
.local.md- Base URL
- Client ID
- API Key
- PEM文件路径(绝对路径)
之后可询问用户是否要将这些信息保存到以便后续使用。
.local.md.local.md
Format
.local.md.local.md
格式
.local.mdmarkdown
undefinedmarkdown
undefinedOnchain-Pay Accounts
Onchain-Pay 账户
prod (default)
prod (default)
- Base URL: https://api.commonservice.io
- Client ID: your-client-id
- API Key: your-api-key
- PEM Path: /absolute/path/to/your/private.pem
- Default Network: your-preferred-network
- Default Address: your-wallet-address
- Description: Production account
The account marked `(default)` is used automatically. You can define multiple accounts and switch by telling Claude the account name.
---- Base URL: https://api.commonservice.io
- Client ID: your-client-id
- API Key: your-api-key
- PEM Path: /absolute/path/to/your/private.pem
- Default Network: your-preferred-network
- Default Address: your-wallet-address
- Description: 生产环境账户
标记为`(default)`的账户会被自动使用。你可以定义多个账户,通过告诉Claude账户名来切换使用。
---User Agent Header
User-Agent 请求头
Include header with the following string:
User-Agentonchain-pay-open-api/0.1.0 (Skill)请求中需要携带头,值为:
User-Agentonchain-pay-open-api/0.1.0 (Skill)Agent Behavior
Agent 行为规范
- If the user asks to call an Onchain-Pay API endpoint, identify which endpoint from the Quick Reference table
- Ask for any missing required parameters
- Use stored credentials if available, otherwise ask the user
- Execute the request using the bundled
scripts/sign_and_call.sh - Display the response in a readable format
- If the request fails, show the error and suggest fixes
- 如果用户要求调用Onchain-Pay API接口,先从快速参考表中识别对应的接口
- 询问用户补全所有缺失的必填参数
- 如果有存储的凭证则直接使用,否则询问用户获取
- 使用内置的执行请求
scripts/sign_and_call.sh - 以易读的格式展示响应结果
- 如果请求失败,展示错误信息并给出修复建议
Important Notes for Pre-order API
预下单API重要注意事项
Timestamp Generation (Cross-platform)
跨平台时间戳生成
When generating timestamps for the parameter and , use the following approach for cross-platform compatibility:
tsexternalOrderIdbash
undefined为参数和生成时间戳时,请使用以下跨平台兼容的方案:
tsexternalOrderIdbash
undefinedGenerate millisecond timestamp (works on macOS, Linux, BSD)
生成毫秒级时间戳(兼容macOS、Linux、BSD)
TIMESTAMP=$(($(date +%s) * 1000))
TIMESTAMP=$(($(date +%s) * 1000))
Generate unique order ID
生成唯一订单ID
ORDER_ID="order$(date +%s)"
**DO NOT USE** `date +%s%3N` or `date +%s000` as these are not portable:
- `date +%s%3N` doesn't work on macOS (outputs literal 'N')
- `date +%s000` just appends '000' without actual millisecond precisionORDER_ID="order$(date +%s)"
**禁止使用** `date +%s%3N` 或 `date +%s000`,因为这两种写法不具备可移植性:
- `date +%s%3N` 在macOS上无法正常工作(会输出字面量'N')
- `date +%s000` 只是简单拼接'000',没有实际毫秒级精度Order ID Format
订单ID格式
The must be a valid string without special characters. Recommended formats:
externalOrderId- (simple numeric suffix)
order1773744500 - (with underscore separator)
order_1773744500 - (custom prefix with alphanumeric)
txn-abc123
Avoid: where TIMESTAMP contains shell variable syntax errors
order_${TIMESTAMP}externalOrderId- (简单数字后缀)
order1773744500 - (带下划线分隔符)
order_1773744500 - (自定义前缀加字母数字组合)
txn-abc123
避免使用:这类包含Shell变量语法错误的格式
order_${TIMESTAMP}Example Pre-order Request
预下单请求示例
bash
undefinedbash
undefinedCorrect way to create a pre-order
创建预订单的正确方式
TIMESTAMP=$(($(date +%s) * 1000))
ORDER_ID="order$(date +%s)"
bash /path/to/scripts/sign_and_call.sh
"https://api.commonservice.io"
"papi/v1/ramp/connect/gray/buy/pre-order"
"connect-gray"
"your-api-key"
"/path/to/private.pem"
"{"externalOrderId":"$ORDER_ID","merchantCode":"connect-gray","merchantName":"YourMerchant","ts":$TIMESTAMP,"fiatCurrency":"USD","requestedAmount":100,"cryptoCurrency":"BNB","amountType":1,"address":"0x...","network":"BSC","payMethodCode":"BUY_CARD"}"
"https://api.commonservice.io"
"papi/v1/ramp/connect/gray/buy/pre-order"
"connect-gray"
"your-api-key"
"/path/to/private.pem"
"{"externalOrderId":"$ORDER_ID","merchantCode":"connect-gray","merchantName":"YourMerchant","ts":$TIMESTAMP,"fiatCurrency":"USD","requestedAmount":100,"cryptoCurrency":"BNB","amountType":1,"address":"0x...","network":"BSC","payMethodCode":"BUY_CARD"}"
undefinedTIMESTAMP=$(($(date +%s) * 1000))
ORDER_ID="order$(date +%s)"
bash /path/to/scripts/sign_and_call.sh
"https://api.commonservice.io"
"papi/v1/ramp/connect/gray/buy/pre-order"
"connect-gray"
"your-api-key"
"/path/to/private.pem"
"{"externalOrderId":"$ORDER_ID","merchantCode":"connect-gray","merchantName":"YourMerchant","ts":$TIMESTAMP,"fiatCurrency":"USD","requestedAmount":100,"cryptoCurrency":"BNB","amountType":1,"address":"0x...","network":"BSC","payMethodCode":"BUY_CARD"}"
"https://api.commonservice.io"
"papi/v1/ramp/connect/gray/buy/pre-order"
"connect-gray"
"your-api-key"
"/path/to/private.pem"
"{"externalOrderId":"$ORDER_ID","merchantCode":"connect-gray","merchantName":"YourMerchant","ts":$TIMESTAMP,"fiatCurrency":"USD","requestedAmount":100,"cryptoCurrency":"BNB","amountType":1,"address":"0x...","network":"BSC","payMethodCode":"BUY_CARD"}"
undefined