wxPayRefund()微信退款函数 * * * * * ~~~ /** * 微信支付-退款 * @param $parment_id * @param null $total_fee 不能有小数点 * @param null $refund_fee 不能有小数点 * @return array|成功时返回,其他抛异常 * @throws WxPayException */ function wxPayRefund($parment_id, $total_fee = null, $refund_fee = null) { $model = new \app\common\model\Payment(); if (!$payment = $model->getPaymentByFind(['payment_id' => $parment_id])) { return ['errCode' => -1, 'errMsg' => '交易单号不存在']; } if (setWxpayConfig($payment['mpid'])) { $total_fee = $total_fee ? $total_fee : $payment['money'] * 100; $refund_fee = $refund_fee ? $refund_fee : $payment['money'] * 100; $input = new \WxPayRefund(); $input->SetOut_trade_no($payment['order_number']); $input->SetTotal_fee($total_fee); $input->SetRefund_fee($refund_fee); $input->SetOut_refund_no($payment['order_number']); $input->SetOp_user_id(WxPayConfig::$MCHID); $result = \WxPayApi::refund($input); return $result; } return ['errCode' => -1, 'errMsg' => '没有公众号配置信息']; } ~~~