文件还在测试中

This commit is contained in:
2026-08-08 15:53:53 +08:00
parent 5f1e7adb64
commit 8101177cb5
241 changed files with 18074 additions and 22 deletions
+35
View File
@@ -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', ''),
]);
}
}