国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

alipay-notify.php 974B

123456789101112131415161718192021222324252627
  1. <?php
  2. if (!defined('DEDEINC')) exit('dedebiz');
  3. // 1. 手动加载入口文件
  4. include "../include.php";
  5. // 2. 准备公众号配置参数
  6. $config = include "./alipay.php";
  7. try {
  8. // 实例支付对象
  9. // $pay = \We::AliPayApp($config);
  10. // $pay = new \AliPay\App($config);
  11. $pay = \AliPay\App::instance($config);
  12. $data = $pay->notify();
  13. if (in_array($data['trade_status'], ['TRADE_SUCCESS', 'TRADE_FINISHED'])) {
  14. // @todo 更新订单状态,支付完成
  15. file_put_contents('notify.txt', "收到来自支付宝的异步通知\r\n", FILE_APPEND);
  16. file_put_contents('notify.txt', '订单号:' . $data['out_trade_no'] . "\r\n", FILE_APPEND);
  17. file_put_contents('notify.txt', '订单金额:' . $data['total_amount'] . "\r\n\r\n", FILE_APPEND);
  18. } else {
  19. file_put_contents('notify.txt', "收到异步通知\r\n", FILE_APPEND);
  20. }
  21. } catch (\Exception $e) {
  22. // 异常处理
  23. echo $e->getMessage();
  24. }