88c6ce8ccc
- 迁移为 frontend-web、frontend-electron、backend-web 与 docker 部署结构 - 网页端:订阅门禁二次弹窗、套餐/支付组件化、顶栏分组对齐 - 首页:最近文件与模板库布局优化,缩略图对齐,下载与删除操作 - 新增管理后台、支付与云端文件 API,更新 README 与项目规范 Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1.2 KiB
PHP
42 lines
1.2 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;
|
|
}
|
|
}
|
|
}
|