Skip to content

Commit

Permalink
Update server.md
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue authored Aug 28, 2023
1 parent 38ab6af commit f9c19ff
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/src/6.x/pay/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ $server->handleRefunded(function (Message $message, \Closure $next) {
return $server->serve();
```

> 🚨 注意:经测试发现官方扔存在[使用 v2 模式的退款推送](https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_16&index=10),所以如果你的退款逻辑有异常,请参考以下方式实现(需要配置 v2 API key):
```php
// 建议使用单独的路由处理退款!
$server = $app->getServer();

// 推送消息,已解密
// 结构参考:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_16&index=10
$message = $server->getReqeustMessage();

// 你的逻辑...

// 返回 SUCCESS 或者 FAIL 等其他状态
return new \Nyholm\Psr7\Response(200, [], \EasyWeChat\Kernel\Support\Xml::build(['return_code' => 'SUCCESS', 'return_msg' => 'OK']));
```

## 其它事件处理

以上便捷方法都只处理了**成功状态**,其它状态,可以通过自定义事件处理中间件的形式处理:
Expand Down

0 comments on commit f9c19ff

Please sign in to comment.