/**
* 退款申请接口-demo
* ====================================================
* 注意:同一笔单的部分退款需要设置相同的订单号和不同的
* out_refund_no。一笔退款失败后重新提交,要采用原来的
* out_refund_no。总退款金额不能超过用户实际支付金额(现
* 金券金额不能退款)。
*/
include_once LIBS_PATH."libraries/wxpaym/WxPayPubHelper.php";
$CI->load->model('order_model','order');
$order = $CI->order->get_one(array('id'=>$_POST["id"]));
//输入需退款的订单号
if (!isset($_POST["id"]))
{
$out_trade_no = " ";
$refund_fee = "1";
}else{
// $out_trade_no = $order$_POST["out_trade_no"];
// $refund_fee = $_POST["refund_fee"];
$out_trade_no = $order['ddbh'];
$refund_fee = 1;
//商户退款单号,商户自定义,此处仅作举例
$out_refund_no = "$out_trade_no".time();
//总金额需与订单号out_trade_no对应,demo中的所有订单的总金额为1分
$total_fee = "$refund_fee";
//使用退款接口
$refund = new Refund_pub();
//设置必填参数
//appid已填,商户无需重复填写
//mch_id已填,商户无需重复填写
//noncestr已填,商户无需重复填写
//sign已填,商户无需重复填写
$refund->setParameter("out_trade_no","$out_trade_no");//商户订单号
$refund->setParameter("out_refund_no","$out_refund_no");//商户退款单号
$refund->setParameter("total_fee","$total_fee");//总金额
$refund->setParameter("refund_fee","$refund_fee");//退款金额
$refund->setParameter("op_user_id",WxPayConf_pub::MCHID);//操作员
//非必填参数,商户可根据实际情况选填
//$refund->setParameter("sub_mch_id","XXXX");//子商户号
//$refund->setParameter("device_info","XXXX");//设备号
//$refund->setParameter("transaction_id","XXXX");//微信订单号
//调用结果
$refundResult = $refund->getResult();
//商户根据实际情况设置相应的处理流程,此处仅作举例
if ($refundResult["return_code"] == "FAIL") {
echo "通信出错:".$refundResult['return_msg']."
";
}
else{
echo "业务结果:".$refundResult['result_code']."
";
echo "错误代码:".$refundResult['err_code']."
";
echo "错误代码描述:".$refundResult['err_code_des']."
";
echo "公众账号ID:".$refundResult['appid']."
";
echo "商户号:".$refundResult['mch_id']."
";
echo "子商户号:".$refundResult['sub_mch_id']."
";
echo "设备号:".$refundResult['device_info']."
";
echo "签名:".$refundResult['sign']."
";
echo "微信订单号:".$refundResult['transaction_id']."
";
echo "商户订单号:".$refundResult['out_trade_no']."
";
echo "商户退款单号:".$refundResult['out_refund_no']."
";
echo "微信退款单号:".$refundResult['refund_idrefund_id']."
";
echo "退款渠道:".$refundResult['refund_channel']."
";
echo "退款金额:".$refundResult['refund_fee']."
";
echo "现金券退款金额:".$refundResult['coupon_refund_fee']."
";
}
}
?>
阅读(1530) | 评论(0) | 转发(0) |