refund.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>退款</title>
  6. </head>
  7. <?php
  8. require_once dirname(dirname(__FILE__)).'/config.php';
  9. require_once dirname(__FILE__).'/service/AlipayTradeService.php';
  10. require_once dirname(__FILE__).'/buildermodel/AlipayTradeRefundContentBuilder.php';
  11. //商户订单号,商户网站订单系统中唯一订单号
  12. $out_trade_no = trim($_POST['WIDTRout_trade_no']);
  13. //支付宝交易号
  14. $trade_no = trim($_POST['WIDTRtrade_no']);
  15. //请二选一设置
  16. //需要退款的金额,该金额不能大于订单金额,必填
  17. $refund_amount = trim($_POST['WIDTRrefund_amount']);
  18. //退款的原因说明
  19. $refund_reason = trim($_POST['WIDTRrefund_reason']);
  20. //标识一次退款请求,同一笔交易多次退款需要保证唯一,如需部分退款,则此参数必传
  21. $out_request_no = trim($_POST['WIDTRout_request_no']);
  22. //构造参数
  23. $RequestBuilder=new AlipayTradeRefundContentBuilder();
  24. $RequestBuilder->setOutTradeNo($out_trade_no);
  25. $RequestBuilder->setTradeNo($trade_no);
  26. $RequestBuilder->setRefundAmount($refund_amount);
  27. $RequestBuilder->setOutRequestNo($out_request_no);
  28. $RequestBuilder->setRefundReason($refund_reason);
  29. $aop = new AlipayTradeService($config);
  30. /**
  31. * alipay.trade.refund (统一收单交易退款接口)
  32. * @param $builder 业务参数,使用buildmodel中的对象生成。
  33. * @return $response 支付宝返回的信息
  34. */
  35. $response = $aop->Refund($RequestBuilder);
  36. var_dump($response);;
  37. ?>
  38. </body>
  39. </html>