pay-order-notify.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2022 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | github开源项目:https://github.com/zoujingli/WeChatDeveloper
  12. // +----------------------------------------------------------------------
  13. try {
  14. // 1. 手动加载入口文件
  15. include "../include.php";
  16. // 2. 准备公众号配置参数
  17. $config = include "./config.php";
  18. // 3. 创建接口实例
  19. // $wechat = new \WeChat\Pay($config);
  20. // $wechat = \We::WeChatPay($config);
  21. $wechat = \WeChat\Pay::instance($config);
  22. // 4. 获取通知参数
  23. $data = $wechat->getNotify();
  24. if ($data['return_code'] === 'SUCCESS' && $data['result_code'] === 'SUCCESS') {
  25. // @todo 去更新下原订单的支付状态
  26. $order_no = $data['out_trade_no'];
  27. // 返回接收成功的回复
  28. ob_clean();
  29. echo $wechat->getNotifySuccessReply();
  30. }
  31. } catch (Exception $e) {
  32. // 出错啦,处理下吧
  33. echo $e->getMessage() . PHP_EOL;
  34. }