四、支付下单 API
POST https://www.vmshell.win/api/v1/pay.php
| 参数 | 类型 | 必填 | 说明 |
app_id | string | 是 | 商户应用 ID。 |
order_id | string | 是 | 商户唯一订单号。 |
amount | decimal | 是 | 订单金额,单位为主币,例如 12.50。 |
currency | string | 否 | 默认 USD。 |
payment_method | string | 否 | alipay 或 wechat,默认按平台通道策略选择。 |
subject | string | 是 | 商品标题,会映射到 Heepay subject。 |
body | string | 否 | 商品描述,会映射到 Heepay body。 |
notify_url | url | 是 | 平台完成支付、退款、争议处理后通知商户的地址。 |
return_url | url | 否 | 用户支付完成后跳转地址。 |
client_ip | string | 否 | 买家 IP,可透传至 Heepay。 |
ext_param | string/json | 否 | 商户扩展参数,平台回调时原样返回。 |
sign | string | 是 | 请求签名。 |
{
"code": 0,
"message": "success",
"data": {
"transaction_id": "VMP_TX_202605280001",
"order_id": "ORDER_10001",
"pay_url": "https://crosspay.heepay.com/pay?...",
"status": "processing",
"platform_fee": "0.18",
"merchant_net_amount": "9.82"
}
}
七、多语言示例代码
PHP
<?php
$params = [
'app_id' => 'YOUR_APP_ID',
'order_id' => 'ORDER_' . time(),
'amount' => '10.00',
'currency' => 'USD',
'subject' => 'Demo Order',
'notify_url' => 'https://merchant.example.com/pay/notify',
'timestamp' => time()
];
ksort($params);
$pairs = [];
foreach ($params as $k => $v) { if ($v !== '' && $v !== null) $pairs[] = $k . '=' . $v; }
$params['sign'] = strtolower(md5(implode('&', $pairs) . '&key=YOUR_APP_SECRET'));
$ch = curl_init('https://www.vmshell.win/api/v1/pay.php');
curl_setopt_array($ch, [CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($params), CURLOPT_RETURNTRANSFER => true]);
echo curl_exec($ch);
Node.js
const crypto = require('crypto');
const axios = require('axios');
const params = { app_id:'YOUR_APP_ID', order_id:'ORDER_' + Date.now(), amount:'10.00', currency:'USD', subject:'Demo Order', notify_url:'https://merchant.example.com/pay/notify', timestamp:Math.floor(Date.now()/1000) };
const base = Object.keys(params).sort().map(k => `${k}=${params[k]}`).join('&');
params.sign = crypto.createHash('md5').update(base + '&key=YOUR_APP_SECRET').digest('hex').toLowerCase();
axios.post('https://www.vmshell.win/api/v1/pay.php', params).then(r => console.log(r.data));
Python
import hashlib, time, requests
params = {'app_id':'YOUR_APP_ID','order_id':f'ORDER_{int(time.time())}','amount':'10.00','currency':'USD','subject':'Demo Order','notify_url':'https://merchant.example.com/pay/notify','timestamp':str(int(time.time()))}
base = '&'.join([f'{k}={params[k]}' for k in sorted(params.keys()) if params[k]])
params['sign'] = hashlib.md5((base + '&key=YOUR_APP_SECRET').encode()).hexdigest().lower()
print(requests.post('https://www.vmshell.win/api/v1/pay.php', data=params).json())
Java
Map<String, String> p = new TreeMap<>();
p.put("app_id", "YOUR_APP_ID"); p.put("order_id", "ORDER_10001"); p.put("amount", "10.00"); p.put("currency", "USD"); p.put("subject", "Demo Order");
String base = p.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining("&"));
String sign = DigestUtils.md5Hex(base + "&key=YOUR_APP_SECRET").toLowerCase();
// 使用 HttpClient POST 至 https://www.vmshell.win/api/v1/pay.php
Go
params := map[string]string{"app_id":"YOUR_APP_ID","order_id":"ORDER_10001","amount":"10.00","currency":"USD","subject":"Demo Order"}
keys := make([]string, 0, len(params)); for k := range params { keys = append(keys, k) }; sort.Strings(keys)
parts := []string{}; for _, k := range keys { parts = append(parts, k+"="+params[k]) }
sum := md5.Sum([]byte(strings.Join(parts, "&") + "&key=YOUR_APP_SECRET"))
params["sign"] = hex.EncodeToString(sum[:])
// http.PostForm("https://www.vmshell.win/api/v1/pay.php", url.Values{...})