Webhook
您可以在网关GUI界面上设置一个WebhookURL。当有事件时,网关将事件通知给WebhookURL。Webhook的一个典型例子是,当订单的支付状态发生更改时,就会出现事件通知。
每当订单状态发生变化时,一个GET请求将被发送到WebhookURL,其参数如下:
| name | type | desc |
|---|---|---|
| type | string | 事件类型,固定值为order |
| instance | string | merchant_order_id 字段,商家传递的订单号 |
| code | string | 事件代码,固定值为statuschange |
| message | string | 订单状态变更说明 |
| signature | string | 请求签名 |
请求可以通过签名规则进行签名验证,签名规则中的
apiUrl使用的是webhook的完整地址如果
webhook地址响应为200,则通知成功,否则会重复通知,每5秒重复一次,最多6次收到
webhook通知时,需要验证参数。 验证过程请参考下方签名计算部分。请注意,签名用于验证
webhook是否来自支付网关。 您应该使用与其他 API 调用相同的算法来验证签名。
Message#
message 字段值
| value | instruction |
|---|---|
| Order Timeout | 订单超时 |
| Order Closed | 订单关闭 |
| Order Paid | 订单已支付 |
| Order Refunded | 订单部分全额或部分退款 |
Webhook 通知示例#
| URL | webhook address |
|---|---|
| Method | GET |
请求内容#
查询字符串示例#
在Postman中演示#

测试 Webhook 端点#
If you don't have public url you can setup Webhook URL to send some test webhook like https://webhook.site
or you can read info about Test WebHook registration with request logging site from Microsoft.
如果您还没有域名,您可以设置例如 https://webhook.site 这样的 Webhook URL 来进行测试。
或者您可以从 Microsoft 获取相关信息 Test WebHook registration with request logging site 。