开发者 API
VMESH Payment API、Webhook 与 Pay Button 集成
创建支付请求、查询公开状态或接收签名 webhook。你的服务器永远不会向 VargaMesh Pay 共享钱包私钥。
商户快速开始
生产环境中请在服务器端创建支付,将客户重定向到 checkout_url,并且仅在签名 Webhook 报告 payment.paid 或 payment.overpaid 后履行订单。
- 1. 服务器通过 POST /api/v1/payments 创建支付。
- 2. 将客户重定向到 API 返回的 checkout_url。
- 3. 验证传入 Webhook 的 X-VMESH-Pay-Signature。
- 4. 仅在 payment.paid 或 payment.overpaid 时将订单标记为已支付。
curl -X POST https://pay.vargamesh.com/api/v1/payments \
-H 'X-VMESH-Pay-API-Key: YOUR_KEY' \
-H 'Content-Type: application/json' \
-d '{"use_address_pool":true,"amount":"125.00","description":"Order #1841","confirmations_required":2,"expires_in":1800,"webhook_url":"https://shop.example/vmesh/webhook"}'可嵌入 Pay Button
捐赠、账单和简单结账链接只需一个 script 与 <vmesh-pay-button> 元素;API Key 不会暴露在浏览器。
<script src="https://pay.vargamesh.com/assets/vmesh-pay-button.js" async></script>
<vmesh-pay-button recipient="shop.vmesh" amount="25" label="My Shop" reference="Order #1841" confirmations="2" expires="1800" lang="zh">Pay with VMESH</vmesh-pay-button>支持属性:recipient、amount、label、reference、confirmations、expires、lang 和 theme。
PHP 示例
<?php
$payload = json_encode([
'use_address_pool' => true,
'amount' => '125.00',
'description' => 'Order #1841',
'confirmations_required' => 2,
'expires_in' => 1800,
'webhook_url' => 'https://shop.example/vmesh/webhook',
]);
$ch = curl_init('https://pay.vargamesh.com/api/v1/payments');
curl_setopt_array($ch, [CURLOPT_POST=>true, CURLOPT_POSTFIELDS=>$payload, CURLOPT_RETURNTRANSFER=>true, CURLOPT_HTTPHEADER=>['Content-Type: application/json','X-VMESH-Pay-API-Key: '.getenv('VMESH_PAY_API_KEY')]]);
$payment = json_decode(curl_exec($ch), true);
header('Location: '.$payment['checkout_url']);Node/JavaScript 示例
const response = await fetch('https://pay.vargamesh.com/api/v1/payments', {
method: 'POST',
headers: {'Content-Type':'application/json','X-VMESH-Pay-API-Key':process.env.VMESH_PAY_API_KEY},
body: JSON.stringify({use_address_pool:true, amount:'125.00', description:'Order #1841', confirmations_required:2, expires_in:1800, webhook_url:'https://shop.example/vmesh/webhook'})
});
const payment = await response.json();
// Redirect the customer to payment.checkout_url市场价格 API
GET /api/v1/market 返回本站使用的缓存 NestEx VMESH/USDT 行情。它不是保证成交价格。
GET /api/v1/market商户收款地址池
通过 POST /api/v1/merchant/addresses 导入新的公开 VMESH 收款地址,然后使用 "use_address_pool": true 创建支付并省略 recipient。每个地址只分配一次,不会自动重复使用。
Webhook 验证
每个 webhook 都包含 X-VMESH-Pay-Signature: sha256=…。请使用配置的 webhook 密钥,对完整请求正文验证 HMAC-SHA256。
X-VMESH-Pay-Event: payment.paid
X-VMESH-Pay-Signature: sha256=<hex HMAC>安全检查清单
API_KEY 与 WEBHOOK_SECRET 仅保存在服务器端;订单使用新的收款地址、HTTPS Webhook、验证 HMAC 签名并以幂等方式更新订单。
无需托管即可集成 VMESH 支付
VargaMesh Pay 将支付协调与钱包托管分离。商户可使用自己的公开收款地址、监控链上结算,并通过签名 Webhook 连接订单系统。
