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.
 
 
 
 
 
 

71 regels
2.9 KiB

  1. <html>
  2. <head>
  3. <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
  4. <meta name="viewport" content="width=device-width, initial-scale=1" />
  5. <title>微信支付样例-退款</title>
  6. </head>
  7. <?php
  8. ini_set('date.timezone','Asia/Shanghai');
  9. error_reporting(E_ERROR);
  10. require_once "../lib/WxPay.Api.php";
  11. require_once 'log.php';
  12. //初始化日志
  13. $logHandler= new CLogFileHandler("../logs/".date('Y-m-d').'.log');
  14. $log = Log::Init($logHandler, 15);
  15. function printf_info($data)
  16. {
  17. foreach($data as $key=>$value){
  18. echo "<font color='#f00;'>$key</font> : $value <br/>";
  19. }
  20. }
  21. if(isset($_REQUEST["transaction_id"]) && $_REQUEST["transaction_id"] != ""){
  22. $transaction_id = $_REQUEST["transaction_id"];
  23. $total_fee = $_REQUEST["total_fee"];
  24. $refund_fee = $_REQUEST["refund_fee"];
  25. $input = new WxPayRefund();
  26. $input->SetTransaction_id($transaction_id);
  27. $input->SetTotal_fee($total_fee);
  28. $input->SetRefund_fee($refund_fee);
  29. $input->SetOut_refund_no(WxPayConfig::MCHID.date("YmdHis"));
  30. $input->SetOp_user_id(WxPayConfig::MCHID);
  31. printf_info(WxPayApi::refund($input));
  32. exit();
  33. }
  34. //$_REQUEST["out_trade_no"]= "122531270220150304194108";
  35. ///$_REQUEST["total_fee"]= "1";
  36. //$_REQUEST["refund_fee"] = "1";
  37. if(isset($_REQUEST["out_trade_no"]) && $_REQUEST["out_trade_no"] != ""){
  38. $out_trade_no = $_REQUEST["out_trade_no"];
  39. $total_fee = $_REQUEST["total_fee"];
  40. $refund_fee = $_REQUEST["refund_fee"];
  41. $input = new WxPayRefund();
  42. $input->SetOut_trade_no($out_trade_no);
  43. $input->SetTotal_fee($total_fee);
  44. $input->SetRefund_fee($refund_fee);
  45. $input->SetOut_refund_no(WxPayConfig::MCHID.date("YmdHis"));
  46. $input->SetOp_user_id(WxPayConfig::MCHID);
  47. printf_info(WxPayApi::refund($input));
  48. exit();
  49. }
  50. ?>
  51. <body>
  52. <form action="#" method="post">
  53. <div style="margin-left:2%;color:#f00">微信订单号和商户订单号选少填一个,微信订单号优先:</div><br/>
  54. <div style="margin-left:2%;">微信订单号:</div><br/>
  55. <input type="text" style="width:96%;height:35px;margin-left:2%;" name="transaction_id" /><br /><br />
  56. <div style="margin-left:2%;">商户订单号:</div><br/>
  57. <input type="text" style="width:96%;height:35px;margin-left:2%;" name="out_trade_no" /><br /><br />
  58. <div style="margin-left:2%;">订单总金额(分):</div><br/>
  59. <input type="text" style="width:96%;height:35px;margin-left:2%;" name="total_fee" /><br /><br />
  60. <div style="margin-left:2%;">退款金额(分):</div><br/>
  61. <input type="text" style="width:96%;height:35px;margin-left:2%;" name="refund_fee" /><br /><br />
  62. <div align="center">
  63. <input type="submit" value="提交退款" style="width:210px; height:50px; border-radius: 15px;background-color:#FE6714; border:0px #FE6714 solid; cursor: pointer; color:white; font-size:16px;" type="button" onclick="callpay()" />
  64. </div>
  65. </form>
  66. </body>
  67. </html>