where(['pay_way' => PayEnum::ALI_PAY])->findOrEmpty()->toArray(); if (empty($config['id'])) { throw new \Exception('请配置好支付设置'); } $initData = [ 'terminal' => $terminal, 'config' => $config, 'pay_way' => PayEnum::ALI_PAY, ]; switch ($config['config']['merchant_type'] . '-' . $config['config']['mode']) { // 普通商户 普通加密 case 'ordinary_merchant-normal_mode': $this->pay = new AlipayV2Default($initData); break; // 服务商 普通加密 case 'service-normal_mode': $this->pay = new AlipayV2Service($initData); break; // 普通商户 证书加密 case 'normal-v3': $this->pay = new AlipayV3Default($initData); break; // 服务商 证书加密 case 'service-v3': $this->pay = new AlipayV3Service($initData); break; default: throw new \Exception('不支持的支付方式'); } } function realPay() { return $this->pay; } function pay($form, $order) { return $this->pay->pay($form, $order); } function notify($data) { $this->pay->set_params([ 'notify_data' => $data ]); return $this->pay->payNotify(); } function checkPay($orderSn) { $this->pay->set_params([ 'query_pay_data' => [ 'order_sn' => $orderSn ] ]); return $this->pay->queryPay(); } function refund($orderSn, $orderAmount, $outRequestNo) { $this->pay->set_params([ 'refund_data' => [ 'order_sn' => $orderSn, 'order_amount' => $orderAmount, 'out_request_no' => $outRequestNo, ] ]); return $this->pay->refund(); } function queryRefund($orderSn, $refundSn) { $this->pay->set_params([ 'query_refund_data' => [ 'order_sn' => $orderSn, 'refund_sn' => $refundSn, ] ]); return $this->pay->queryRefund(); } }