findOrEmpty()->toArray(); if (empty($config['id'])) { throw new \Exception('请配置好支付设置'); } $initData = [ 'terminal' => $terminal, 'config' => $config, 'pay_way' => PayEnum::WECHAT_PAY, 'user_id' => $userId ]; switch ($config['config']['merchant_type'] . '-' . $config['config']['interface_version']) { // 普通商户 v2 case 'ordinary_merchant-v2': $this->pay = new WechatPayV2Default($initData); break; // 普通商户 v3 case 'ordinary_merchant-v3': // 服务商子商户 v3 case 'partner_sub_merchant-v3': $this->pay = new WechatPayV3Default($initData); break; // 服务商 v3 case 'partner_merchant-v3': throw new \Exception('不支持 服务商的支付方式'); break; default: throw new \Exception('不支持的支付方式'); } } function realPay() { return $this->pay; } function pay($form, $order) { return $this->pay->pay($form, $order); } /** * @notes 支付回调 * @return \Symfony\Component\HttpFoundation\Response * @throws \EasyWeChat\Kernel\Exceptions\Exception * @author 段誉 * @date 2021/8/13 14:19 */ public function notify() { return $this->pay->payNotify(); } /** * @notes 退款 * @param $data //微信订单号、商户退款单号、订单金额、退款金额、其他参数 * @return bool * @author 段誉 * @date 2021/8/4 14:57 */ public function refund($data) { $this->pay->set_params([ 'refund_data' => $data ]); return $this->pay->refund(); } function queryRefund($refund) { $this->pay->set_params([ 'query_refund_data' => $refund ]); return $this->pay->queryRefund(); } }