注册商家
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']}")