🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
官方文档:https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_5 ## 函数 ``` /** * 微信支付 - 退款查询 * 微信订单号、商户订单号、微信订单号、微信退款单号选填至少一个,微信退款单号优先: * @param $transaction_id 微信订单号 * @param $out_trade_no 商户订单号 * @param $out_refund_no 商户退款单号 * @param $refund_id 微信退款单号 */ function wxpayRefundQuery($transaction_id,$out_trade_no='',$out_refund_no='',$refund_id='') { //导入 WxPay.Api.php 类 import('WxpayAPI.lib.WxPay',EXTEND_PATH,'.Api.php'); //导入 WxPay.Data.php 类 import('WxpayAPI.lib.WxPay',EXTEND_PATH,'.Data.php'); $input = new WxPayRefundQuery(); $input->SetTransaction_id($transaction_id); //微信订单号 $input->SetOut_trade_no($out_trade_no); //商户订单号 $input->SetOut_refund_no($out_refund_no); //商户退款单号 $input->SetRefund_id($refund_id); //微信退款单号 dump(WxPayApi::refundQuery($input)); } ``` ## 使用方法 ``` // 微信支付 - 退款单查询 public function refundQueryTest() { // 微信订单号 查询 //wxpayRefundQuery('4200000011201709193042132589'); // 商户订单号 查询 //wxpayRefundQuery('','2017091910048541'); // 商户订单号 查询(注意:这里查的是 out_refund_no_0 而不是out_refund_no) //wxpayRefundQuery('','','140480710220170919233847'); // 商户订单号 查询(注意:这里查的是 refund_id_0) wxpayRefundQuery('','','','50000504262017091901789042036'); } ``` ## 回调结果 ``` array(21) { ["appid"] => string(18) "wx92dedc49b3405e25" ["cash_fee"] => string(3) "100" ["mch_id"] => string(10) "1404807102" ["nonce_str"] => string(16) "3sCT0kOu5s4Qzvik" ["out_refund_no_0"] => string(24) "140480710220170919233847" ["out_trade_no"] => string(16) "2017091910048541" ["refund_account_0"] => string(29) "REFUND_SOURCE_UNSETTLED_FUNDS" ["refund_channel_0"] => string(8) "ORIGINAL" ["refund_count"] => string(1) "1" ["refund_fee"] => string(2) "10" ["refund_fee_0"] => string(2) "10" ["refund_id_0"] => string(29) "50000504262017091901789042036" ["refund_recv_accout_0"] => string(25) "工商银行信用卡1776" ["refund_status_0"] => string(7) "SUCCESS" ["refund_success_time_0"] => string(19) "2017-09-20 01:10:18" ["result_code"] => string(7) "SUCCESS" ["return_code"] => string(7) "SUCCESS" ["return_msg"] => string(2) "OK" ["sign"] => string(32) "5A3CCE18590454385B11C0BB4634A55F" ["total_fee"] => string(3) "100" ["transaction_id"] => string(28) "4200000011201709193042132589" } ``` ## 官方示例如下: ![mark](http://qiniu.newthink.cc/blog/20170920-110205127.png)