Files
SoonDesign/backend-web/src/Services/PaymentConfigLoader.php
T
24kycj 152228d41f 前端配置迁至 config/local.js,完善支付、模板库与部署脚本
- 页面直接引用 local.js 设置 SOON_DEPLOY_CONFIG,移除 deploy-config
- Docker sync-config 生成 local.js;更新 README 与 agent-core 说明
- 模板库自动扫描 .soon;新增后端部署/种子/排查脚本
- 完善支付配置、订阅弹窗与后台支付管理页

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 20:48:51 +08:00

48 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Soon\Api\Services;
/**
* 从 storage/payment/*.pem 合并支付密钥到 Config。
*/
final class PaymentConfigLoader
{
public static function merge(array &$config): void
{
$dir = SOON_SERVER_ROOT . '/storage/payment';
if (!is_dir($dir)) {
return;
}
$map = [
'alipay_private_key.pem' => ['alipay', 'private_key'],
'alipay_public_key.pem' => ['alipay', 'public_key'],
'wechat_mch_private_key.pem' => ['wechat', 'mch_private_key'],
'wechat_api_v3_key.pem' => ['wechat', 'api_v3_key'],
'wechat_platform_cert.pem' => ['wechat', 'platform_cert'],
];
foreach ($map as $file => [$section, $key]) {
$path = $dir . '/' . $file;
if (!is_file($path)) {
continue;
}
$content = trim((string)file_get_contents($path));
if ($content === '') {
continue;
}
if (!isset($config[$section]) || !is_array($config[$section])) {
$config[$section] = [];
}
$config[$section][$key] = $content;
}
}
public static function reload(array &$config): void
{
self::merge($config);
SettingsConfigLoader::merge($config);
}
}