12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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),
-
-
-
-
-
-
-
-
- 'app_id' => $result['config']['app_id'] ?? '',
-
- 'sign_type' => 'RSA2',
-
-
- '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',
- ],
-
-
-
- ];
- }
- }
|