jh-admin/addon/saas/model/MinCode.php

46 lines
2.6 KiB
PHP
Raw Permalink 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
namespace addon\saas\model;
use Alipay\EasySDK\Kernel\Config as AliSdkCon;
use Alipay\EasySDK\Kernel\Factory;
class MinCode extends \addon\aliapp\model\MinCode
{
public function __construct($site_id = '')
{
// 获取支付宝支付参数(统一支付到平台账户)
$config_model = new Config();
$this->site_id = $site_id;
$this->platform = config('alipay.platform');
if ($site_id) {
$config_info = $config_model->getMiniConfig($site_id)['data']['value'];
$this->uconfig = $config_info;
if (isset($config_info['line_type']) && $config_info['line_type'] == 'auth') {
$this->appAuthToken = $this->uconfig['app_auth_token'];
$config_info = $this->platform;
}
} else {
$config_info = config('alipay.platform');
}
$this->config = $config_info;
$options = new AliSdkCon();
$options->protocol = 'https';
$options->gatewayHost = 'openapi.alipay.com';
$options->signType = 'RSA2';
$options->appId = $config_info['appid'] ?? '';
// 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中
$options->merchantPrivateKey = $config_info['private_key'] ?? ""; //'<-- 请填写您的应用私钥例如MIIEvQIBADANB ... ... -->';
$options->alipayCertPath = ''; //'<-- 请填写您的支付宝公钥证书文件路径,例如:/foo/alipayCertPublicKey_RSA2.crt -->';
$options->alipayRootCertPath = ''; //'<-- 请填写您的支付宝根证书文件路径,例如:/foo/alipayRootCert.crt" -->';
$options->merchantCertPath = ''; //'<-- 请填写您的应用公钥证书文件路径,例如:/foo/appCertPublicKey_2019051064521003.crt -->';
//注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可
$options->alipayPublicKey = $config_info['alipay_public_key'] ?? ""; // '<-- 请填写您的支付宝公钥例如MIIBIjANBg... -->';
//可设置异步通知接收服务地址(可选)
$options->notifyUrl = ''; //"<-- 请填写您的支付类接口异步通知接收服务地址例如https://www.test.com/callback -->";
//可设置AES密钥调用AES加解密相关接口时需要可选
$options->encryptKey = $config_info['encryptKey'] ?? ''; // 'du/cSQ7P4YPw4d8+3jUc3w=='; //"<-- 请填写您的AES密钥例如aa4BtZ4tspm2wnXLb1ThQA== -->";
Factory::setOptions($options);
}
}