alipay-refund.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2023 ThinkAdmin [ thinkadmin.top ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // | 免责声明 ( https://thinkadmin.top/disclaimer )
  11. // +----------------------------------------------------------------------
  12. // | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
  13. // | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
  14. // +----------------------------------------------------------------------
  15. // 1. 手动加载入口文件
  16. include "../include.php";
  17. // 2. 准备公众号配置参数
  18. $config = include "./alipay.php";
  19. // 原商户订单号
  20. $out_trade_no = '56737188841424';
  21. // 申请退款金额
  22. $refund_fee = '1.00';
  23. try {
  24. // 实例支付对象
  25. // $pay = We::AliPayApp($config);
  26. // $pay = new \AliPay\App($config);
  27. $pay = \AliPay\App::instance($config);
  28. // 参考链接:https://docs.open.alipay.com/api_1/alipay.trade.refund
  29. $result = $pay->refund($out_trade_no, $refund_fee);
  30. echo '<pre>';
  31. var_export($result);
  32. } catch (Exception $e) {
  33. echo $e->getMessage();
  34. }