增加发货平台 2
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
订单异步通知
|
||||
创建订单时可传入 notify_url。当该订单充值状态发生变化时,平台将向该地址 POST JSON 通知(队列异步发送,失败自动重试)。
|
||||
|
||||
#触发时机
|
||||
下单成功创建订单后(首次状态,如 15 待绑定)
|
||||
之后每次 recharge_status 变更(如 17 已提交、30 成功、40 失败等)
|
||||
仅 开放 API 订单(platform=api)且下单时传了有效 notify_url 才会推送。
|
||||
|
||||
#商户接收要求
|
||||
项目 说明
|
||||
方法 POST
|
||||
Content-Type application/json
|
||||
成功响应 HTTP 2xx(建议返回 {"code":0} 或纯文本 OK)
|
||||
超时 平台默认 10 秒,超时或 5xx 将按队列重试(默认最多 5 次)
|
||||
#签名
|
||||
Header:
|
||||
|
||||
Header 说明
|
||||
X-App-Key 您的 App Key
|
||||
X-Timestamp Unix 秒级时间戳
|
||||
X-Sign HMAC_SHA256(app_key + timestamp + raw_json_body, app_secret) 小写 hex
|
||||
验签时使用与请求开放 API 完全相同的原始 Body 字符串,勿重新格式化 JSON。
|
||||
|
||||
#通知 Body 结构
|
||||
json
|
||||
{
|
||||
"event": "order.status_changed",
|
||||
"order": {
|
||||
"order_no": "202601011200001234",
|
||||
"platform_order_no": "YOUR-ORDER-001",
|
||||
"platform": "api",
|
||||
"product_code": "10000001",
|
||||
"product_name": "和平精英点券",
|
||||
"recharge_status": 30,
|
||||
"recharge_status_label": "充值成功",
|
||||
"status": 30,
|
||||
"status_label": "充值成功",
|
||||
"points_charged": 3800,
|
||||
"player_account": "123456789",
|
||||
"notify_url": "https://your-server.com/open-api/order-notify",
|
||||
"recharge_finish_at": "2026-01-01 12:30:00",
|
||||
"updated_at": "2026-01-01 12:30:00"
|
||||
}
|
||||
}
|
||||
order 字段与「查询订单」接口结构基本一致(通知中不含 h5 链接;含 product_code)。
|
||||
|
||||
#PHP 验签示例
|
||||
php
|
||||
$rawBody = file_get_contents('php://input');
|
||||
$appKey = $_SERVER['HTTP_X_APP_KEY'] ?? '';
|
||||
$timestamp = $_SERVER['HTTP_X_TIMESTAMP'] ?? '';
|
||||
$sign = $_SERVER['HTTP_X_SIGN'] ?? '';
|
||||
$appSecret = 'your_app_secret';
|
||||
|
||||
$expected = hash_hmac('sha256', $appKey . $timestamp . $rawBody, $appSecret);
|
||||
if (!hash_equals($expected, $sign)) {
|
||||
http_response_code(401);
|
||||
exit('invalid sign');
|
||||
}
|
||||
|
||||
$data = json_decode($rawBody, true);
|
||||
// 处理 $data['order'] ...
|
||||
|
||||
http_response_code(200);
|
||||
echo json_encode(['code' => 0]);
|
||||
|
||||
Reference in New Issue
Block a user