config = $data; } /** * 设置参数 * @param string $notify_url 支付宝服务器主动通知商户服务器里指定的页面http/https路径。 * @date 2021-10-25 */ public function getOptions($notify_url = '') { $options = new Config(); $options->protocol = 'https'; $options->gatewayHost = 'openapi.alipay.com'; $options->signType = 'RSA2'; $options->appId = $this->config['app_id']; // 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中 $options->merchantPrivateKey = $this->config['app_private_key']; if ($this->config['sign_type'] == 2) { //公钥证书 $options->alipayCertPath = $this->config['alipay_cert_path']; $options->alipayRootCertPath = $this->config['alipay_root_cert_path']; $options->merchantCertPath = $this->config['merchant_cert_path']; } else if ($this->config['sign_type'] == 1) { //普通公钥 //注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可 $options->alipayPublicKey = $this->config['ali_pay_public_key']; } //可设置异步通知接收服务地址(可选) if (!empty($notify_url)) { $options->notifyUrl = $notify_url; } //可设置AES密钥,调用AES加解密相关接口时需要(可选) if($this->config['encrypt_key']){ $options->encryptKey = $this->config['encrypt_key']; } return $options; } }