🔗

Crypto Payment API

集成加密货币支付聚合器,支持 BTC、ETH、USDT 等多种币种

🚀 快速开始

只需 3 个步骤,即可接入 XcoinPay 加密货币支付系统。

1
创建商家账户
访问商家中心,使用邮箱注册并获取 API Key
2
保存 API Key
妥善保管您的 API Key,用于所有 API 调用的身份验证
3
创建发票
通过 API 或 Dashboard 创建支付发票,收取加密货币

📚 API 参考文档

注册商家账户

创建一个新的商家账户,返回 API Key。

请求参数

参数 类型 必需 说明
name string 商家名称
email string 商家邮箱地址
webhookUrl string 接收支付回调的 URL

响应示例

{ "success": true, "apiKey": "sk_live_1a2b3c4d5e6f7g8h", "merchant": { "id": "merchant_123", "name": "My Store", "email": "[email protected]", "createdAt": "2025-05-14T00:00:00Z" } }

商家登录

使用邮箱和 API Key 进行登录验证。

请求参数

参数 类型 必需 说明
email string 商家邮箱
apiKey string API Key

创建支付发票

创建一个新的支付发票,客户可以通过此发票进行支付。

请求头

x-api-key: YOUR_API_KEY

请求参数

参数 类型 必需 说明
priceAmount number 金额,如 100.50
priceCurrency string 法币类型:usd, eur, gbp
payCurrency string 付款币种:btc, eth, usdt, usdc, bnb 等
orderId string 商家订单 ID
description string 订单描述
callbackUrl string 支付完成后的回调 URL

响应示例

{ "success": true, "invoiceId": "inv_1234567890", "invoiceLink": "https://xcoinpay.com/pay/inv_1234567890", "priceAmount": 100.50, "priceCurrency": "usd", "payCurrency": "btc", "expiresAt": "2025-05-15T00:00:00Z" }

查询发票列表

获取该商家的所有发票列表及状态。

请求头

x-api-key: YOUR_API_KEY

查询参数

参数 类型 说明
limit number 返回条数,默认 20
page number 分页页码,默认 0

响应示例

{ "success": true, "data": [ { "id": "inv_1234567890", "priceAmount": 100.50, "priceCurrency": "usd", "payCurrency": "btc", "status": "pending", "createdAt": "2025-05-14T00:00:00Z" } ] }

Webhook 回调

支付完成后,XcoinPay 会向您的 Webhook URL 发送回调通知。

Webhook 消息格式

{ "event": "payment.completed", "invoiceId": "inv_1234567890", "status": "completed", "amountReceived": "0.00123456", "payCurrency": "btc", "orderId": "order_001", "transactionId": "tx_abc123...", "confirmedAt": "2025-05-14T10:30:00Z", "signature": "hmac_signature_for_verification" }

重要说明

  • 您的 Webhook URL 必须在 5 秒内响应 200 OK
  • 请验证 signature 以确保请求来自 XcoinPay
  • 如果 Webhook 失败,我们将重试 3 次

💻 代码示例

注册商家

curl -X POST https://xcoinpay.com/api/merchant/register \ -H "Content-Type: application/json" \ -d '{ "name": "My Store", "email": "[email protected]", "webhookUrl": "https://your-domain.com/webhook" }'

创建发票

curl -X POST https://xcoinpay.com/api/merchant/invoice \ -H "Content-Type: application/json" \ -H "x-api-key: YOUR_API_KEY" \ -d '{ "priceAmount": 100.50, "priceCurrency": "usd", "payCurrency": "btc", "orderId": "order_001", "description": "Product purchase" }'

查询发票列表

curl -X GET https://xcoinpay.com/api/merchant/invoices \ -H "x-api-key: YOUR_API_KEY"

创建发票

const apiKey = 'YOUR_API_KEY'; fetch('https://xcoinpay.com/api/merchant/invoice', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': apiKey }, body: JSON.stringify({ priceAmount: 100.50, priceCurrency: 'usd', payCurrency: 'btc', orderId: 'order_001', description: 'Product purchase' }) }) .then(res => res.json()) .then(data => { console.log('Invoice created:', data.invoiceLink); }) .catch(err => console.error('Error:', err));

查询发票列表

fetch('https://xcoinpay.com/api/merchant/invoices', { method: 'GET', headers: { 'x-api-key': apiKey } }) .then(res => res.json()) .then(data => { console.log('Invoices:', data.data); }) .catch(err => console.error('Error:', err));

创建发票

import requests api_key = 'YOUR_API_KEY' url = 'https://xcoinpay.com/api/merchant/invoice' headers = { 'Content-Type': 'application/json', 'x-api-key': api_key } payload = { 'priceAmount': 100.50, 'priceCurrency': 'usd', 'payCurrency': 'btc', 'orderId': 'order_001', 'description': 'Product purchase' } response = requests.post(url, headers=headers, json=payload) data = response.json() if data['success']: print(f"Invoice: {data['invoiceLink']}") else: print(f"Error: {data.get('error')}")

查询发票列表

response = requests.get( 'https://xcoinpay.com/api/merchant/invoices', headers={'x-api-key': api_key} ) data = response.json() for invoice in data['data']: print(f"{invoice['id']}: {invoice['priceAmount']} {invoice['priceCurrency']}")

💰 支持的货币

XcoinPay 支持多种加密货币和法定货币的支付。

加密货币

BTC
Bitcoin
ETH
Ethereum
USDT
Tether (ERC-20 / TRC-20)
USDC
USD Coin
BNB
Binance Coin
XRP
Ripple
SOL
Solana
DOGE
Dogecoin

法定货币

USD
美元
EUR
欧元
GBP
英镑

❓ 常见问题

您可以在商家 Dashboard 中重新生成 API Key。新的 Key 会立即生效,旧 Key 将被废弃。

目前没有严格的速率限制,但建议每秒不超过 10 个请求。如果遇到 429 响应,请等待后重试。

确认时间取决于区块链网络的拥堵情况。一般来说,BTC 需要 10-30 分钟,ETH 需要 1-3 分钟。支付确认后,我们会立即发送 Webhook 通知。

每个 Webhook 请求都包含 signature 字段。使用您的 API Secret 对请求体进行 HMAC-SHA256 签名,如果结果与 signature 相匹配,则证实了请求来自 XcoinPay。

准备好了吗?

立即开始使用 XcoinPay,让您的商业接受全球加密货币支付。