Files
chazhi_shop_backend/app/common/server/YansongdaAliPayServer.php
2026-04-14 17:46:22 +08:00

85 lines
3.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\common\server;
use app\common\model\Pay;
class YansongdaAliPayServer
{
static function _cache_file($key,$content, $ext = 'crt') : string
{
$path = runtime_path() . 'admin/alipay';
if (! file_exists($path)) {
mkdir($path, 0775, true);
}
$file = $path . '/' . $key . '.' . md5($content) . ".{$ext}";
if (! file_exists($file)) {
file_put_contents($file, $content);
}
return $file;
}
static function config()
{
$result = (new Pay())->where([ 'code' => 'alipay' ])->find();
return [
// 支付宝异步通知地址
'notify_url' => (string) url('pay/aliNotify', [], false, true),
// 支付成功后同步通知地址
// 'return_url' => '',
// 支付宝公钥地址 新版已使用证书方式
// 'ali_public_key' => "",
// 支付宝分配的 APPID
'app_id' => $result['config']['app_id'] ?? '',
'sign_type' => 'RSA2',
//商户私钥地址默认沙箱通用私钥如需调试线上环境请换成线上的私钥https://docs.open.alipay.com/291/106103/
'private_key' => $result['config']['private_key'] ?? '',
// 应用公钥证书路径
'app_cert_public_key' => static::_cache_file('app_cert', $result['config']['app_cert'] ?? ''),
// 支付宝根证书路径
'alipay_root_cert' => static::_cache_file('ali_root_cert', $result['config']['ali_root_cert'] ?? ''),
// 公钥证书
'ali_public_key' => static::_cache_file('ali_public_cert', $result['config']['ali_public_cert'] ?? ''),
// 日志
'log' => [
'file' => runtime_path() . 'log/yansongda/log',
],
// optional设置此参数将进入沙箱模式
// 'mode' => 'dev',
];
}
}