时间:2021-07-01 10:21:17 帮助过:14人阅读
1. 上代码:
/**
* 退款
* @author:大脸猫脸大
*/
public function refund()
{
import("Vendor.Wxpay.lib.WxPay#Api", "", ".php");
$orderSn = I("ordersn", "", "trim");
$map = array('ordersn'=> $orderSn);
$order = M("Order")->where($map)->find();
if (!$order) {
$result['code'] = 0;
$result['msg'] = '未找到订单';
$this->ajaxReturn($result);
}
$input = new \WxPayRefund();
$input->SetTotal_fee($order['price']*100);
$input->SetRefund_fee($order['price']*100);
$input->SetOut_refund_no("R".$orderSn);
$input->SetOut_trade_no("$orderSn");
$input->SetOp_user_id(\WxPayConfig::MCHID);
$refundOrder = \WxPayApi::refund($input);
//file_put_contents(__DIR__."/refund.log", var_export($refundOrder, true). "\r\n" , FILE_APPEND);
if ($refundOrder['result_code'] == 'SUCCESS' && $refundOrder['return_code'] == 'SUCCESS') {
$result['code'] = 1;
$result['data'] = $refundOrder['transaction_id'];
$this->ajaxReturn($result);
}
else {
$result['code'] = 0;
$result['msg'] = $refundOrder['err_code'];
$this->ajaxReturn($result);
}
}相关推荐:
微信支付的退款功能开发
PHP实现微信申请退款流程的方法
PHP开发实现微信退款功能详解
以上就是php实现小程序退款完整版的详细内容,更多请关注Gxl网其它相关文章!