文件还在测试中
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace Core\Payment;
|
||||
|
||||
use App\Models\Setting;
|
||||
|
||||
/**
|
||||
* 支付网关工厂:根据后台「支付设置」构建对应通道
|
||||
*/
|
||||
class GatewayFactory
|
||||
{
|
||||
public static function make(string $channel): Gateway
|
||||
{
|
||||
$s = new Setting();
|
||||
$mode = $s->get('pay_mode', 'demo');
|
||||
$enabled = $s->get('pay_enabled', '1');
|
||||
|
||||
if ($channel === 'alipay') {
|
||||
return new AlipayGateway([
|
||||
'mode' => $mode,
|
||||
'enabled' => $enabled,
|
||||
'appid' => $s->get('pay_alipay_appid', ''),
|
||||
'private_key' => $s->get('pay_alipay_private_key', ''),
|
||||
'public_key' => $s->get('pay_alipay_public_key', ''),
|
||||
'gateway' => $s->get('pay_alipay_gateway', 'https://openapi.alipay.com/gateway.do'),
|
||||
]);
|
||||
}
|
||||
return new WechatGateway([
|
||||
'mode' => $mode,
|
||||
'enabled' => $enabled,
|
||||
'mchid' => $s->get('pay_wechat_mchid', ''),
|
||||
'appid' => $s->get('pay_wechat_appid', ''),
|
||||
'key' => $s->get('pay_wechat_key', ''),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user