| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace common\expand\alipay\order\notice;
- use addons\AlipayMchCoupon\common\models\AddonsAlipayMchAlipayNoticeModel;
- use AlibabaCloud\Tea\Exception\TeaError;
- use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
- use AlibabaCloud\Tea\FileForm\FileForm;
- use AlibabaCloud\Tea\FileForm\FileForm\FileField;
- use AlibabaCloud\Tea\Request;
- use AlibabaCloud\Tea\Tea;
- use Alipay\EasySDK\Kernel\CertEnvironment;
- use Alipay\EasySDK\Kernel\Config;
- use Alipay\EasySDK\Kernel\EasySDKKernel;
- use Alipay\EasySDK\Kernel\Factory;
- use common\expand\alipay\AlipayFactory;
- use common\models\order\Order;
- use GuzzleHttp\Psr7\Stream;
- use Yii;
- abstract class AlipayNoticeAbstract
- {
- protected $data = [];
- protected $config = [];
- /**
- * @var AlipayFactory
- */
- protected $alipayFactory;
- public function __construct(array $data)
- {
- $this->data = $data;
- $this->config = \Yii::$app->services->setting->mall->get($data['mall_id'], 'alipay_mini');
- $this->alipayFactory = AlipayFactory::setOptions($this->getOptions());
- }
- /**
- * @return Config
- */
- private function getOptions(): Config
- {
- $options = new Config();
- $options->protocol = 'https';
- $options->gatewayHost = 'openapi.alipay.com';
- // $options->gatewayHost = 'openapi.alipaydev.com'; // 测试环境
- $options->signType = 'RSA2';
- $options->appId = $this->config['app_id'];
- // 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中
- $options->merchantPrivateKey = $this->config['merchantPrivateKey'];
- //$options->alipayCertPath = dirname(Yii::$app->basePath).'/'.$this->config['alipayCertPath'];
- //$options->alipayRootCertPath = dirname(Yii::$app->basePath).'/'.$this->config['alipayCertPath'];
- //$options->merchantCertPath = dirname(Yii::$app->basePath).'/'.$this->config['merchantCertPath'];
- //注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可
- $options->alipayPublicKey = file_get_contents(dirname(Yii::$app->basePath).'/'.$this->config['alipayCertPath']);
- //可设置异步通知接收服务地址(可选)
- $options->notifyUrl = '';
- //可设置AES密钥,调用AES加解密相关接口时需要(可选)
- $options->encryptKey = $this->config['encryptKey'];
- return $options;
- }
- }
|