外观
商户通知
平台会向订单请求中的 notify_url 发送商户通知。通知同样使用签名 + 加密信封,商户需要验签、解密并返回 HTTP 2xx。
通知请求头
| Header | 说明 |
|---|---|
Content-Type | application/json。 |
X-Mch-Id | 平台商户号,商户侧用它定位本地 Open API 配置。 |
X-Timestamp | 平台通知时间戳,Unix 秒。 |
X-Nonce | 平台通知随机串。 |
X-Request-Id | 平台通知请求 ID。 |
X-Signature | 平台对通知密文信封 body 的 HMAC-SHA256 签名。 |
通知 body
json
{
"encrypted_key": "base64(RSA-OAEP(merchant_public_key, content_key))",
"biz_content": "base64(aes_gcm_nonce || aes_gcm_ciphertext || aes_gcm_tag)"
}处理顺序
- 用本地保存的
secret_key和 6 行签名串校验X-Signature。 - 用商户私钥解密
encrypted_key得到本次content_key。 - 用
content_key解密biz_content得到通知业务 JSON。 - 按
notify_type和trade_no做幂等处理。 - 返回 HTTP 2xx 表示接收成功。
非 2xx 会进入平台重试。商户处理通知时应保证幂等,不要因为重复通知造成重复发货、重复入账或重复退款。
收款成功通知示例
解密后的业务 JSON 示例:
json
{
"notify_type": "payin.success",
"trade_no": "260703000842100181368386",
"merchant_order_no": "PAY-OPEN-202607030001",
"trade_type": 1,
"status": 2,
"status_label": "成功",
"amount": "20.000",
"currency_code": "USD",
"fee_amount": "1.200",
"completed_at": "2026-07-03 10:00:00"
}返回要求
商户通知接口返回任意 HTTP 2xx 均表示接收成功。推荐返回:
text
HTTP/1.1 204 No Content如果业务处理失败,应返回非 2xx,让平台重试。不要在签名失败或解密失败时返回 2xx。