/** * * 查询退款情况 * @param string $out_trade_no 商户订单号 * @param int $succCode 查询退款结果 * @return */ public function refundQuery($out_trade_no) { $WxPayRefundQuery = new \WxPayRefundQuery(); $WxPayRefundQuery->SetOut_trade_no($out_trade_no); $WxPayRefundQuery->setWxPayApi($this->wxPayApi); $result = $this->wxPayApi->refundQuery($WxPayRefundQuery, $this->wxPayConfig['CURL_TIMEOUT']); if ($result['return_code'] == 'FAIL') { throw new \WxPayException($result['return_msg']); } if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS') { //退款成功 return true; } return false; }
function printf_info($data) { foreach ($data as $key => $value) { echo "<font color='#f00;'>{$key}</font> : {$value} <br/>"; } } if (isset($_REQUEST["transaction_id"]) && $_REQUEST["transaction_id"] != "") { $transaction_id = $_REQUEST["transaction_id"]; $input = new WxPayRefundQuery(); $input->SetTransaction_id($transaction_id); printf_info(WxPayApi::refundQuery($input)); } if (isset($_REQUEST["out_trade_no"]) && $_REQUEST["out_trade_no"] != "") { $out_trade_no = $_REQUEST["out_trade_no"]; $input = new WxPayRefundQuery(); $input->SetOut_trade_no($out_trade_no); printf_info(WxPayApi::refundQuery($input)); exit; } if (isset($_REQUEST["out_refund_no"]) && $_REQUEST["out_refund_no"] != "") { $out_refund_no = $_REQUEST["out_refund_no"]; $input = new WxPayRefundQuery(); $input->SetOut_refund_no($out_refund_no); printf_info(WxPayApi::refundQuery($input)); exit; } if (isset($_REQUEST["refund_id"]) && $_REQUEST["refund_id"] != "") { $refund_id = $_REQUEST["refund_id"]; $input = new WxPayRefundQuery(); $input->SetRefund_id($refund_id); printf_info(WxPayApi::refundQuery($input));