store_id)->first(); $main_set['sub_appid'] = $sub_set->wx_sub_appid; $main_set['sub_mini_appid'] = $sub_set->wx_sub_mini_appid; $main_set['sub_mchid'] = $sub_set->wx_sub_mchid; if ($main_set['profit_sharing']) { $main_set['profit_sharing'] = !$sub_set->no_profit_sharing ?: 0; } } $this->set = $main_set; } public function getIndependent() { if (!$this->set['is_independent'] && $this->set['sub_appid']) { return true; } return false; } //=======【基本信息设置】===================================== /** * * 微信公众号信息配置 * * APPID:绑定支付的APPID(必须配置,开户邮件中可查看) * * MCHID:商户号(必须配置,开户邮件中可查看) * */ public function GetAppId() { if (\YunShop::request()->type == 2) { return $this->set['mini_appid']; } return $this->set['appid']; } public function GetSubAppId() { if (\YunShop::request()->type == 2 && !$this->set['is_independent'] && $this->set['sub_mini_appid']) { return $this->set['sub_mini_appid']; } return $this->set['sub_appid']; } public function GetMerchantId() { return $this->set['mchid']; } public function GetSubMerchantId() { return $this->set['sub_mchid']; } /** * 是否开启分账 * @return string */ public function GetProfitSharing() { return $this->set['profit_sharing'] ? 'Y' : 'N'; } public function GetMchName() { return $this->set['mch_name']; } //=======【支付相关配置:支付成功回调地址/签名方式】=================================== /** * * 签名和验证签名方式, 支持md5和sha256方式 **/ public function GetNotifyUrl() { return Url::shopSchemeUrl('payment/wechatscan/notifyUrl.php');; } public function GetSignType() { return $this->set['sign_type'] ?: "HMAC-SHA256"; } public function SetSignType($sign_type) { $this->set['sign_type'] = $sign_type; } //=======【curl代理设置】=================================== /** * TODO:这里设置代理机器,只有需要代理的时候才设置,不需要代理,请设置为0.0.0.0和0 * 本例程通过curl使用HTTP POST方法,此处可修改代理服务器, * 默认CURL_PROXY_HOST=0.0.0.0和CURL_PROXY_PORT=0,此时不开启代理(如有需要才设置) * @var unknown_type */ public function GetProxy(&$proxyHost, &$proxyPort) { $proxyHost = "0.0.0.0"; $proxyPort = 0; } //=======【上报信息配置】=================================== /** * TODO:接口调用上报等级,默认紧错误上报(注意:上报超时间为【1s】,上报无论成败【永不抛出异常】, * 不会影响接口调用流程),开启上报之后,方便微信监控请求调用的质量,建议至少开启错误上报。 * 上报等级,0.关闭上报; 1.仅错误出错上报; 2.全量上报 * @return int */ public function GetReportLevenl() { return 0; } //=======【商户密钥信息-需要业务方继承】=================================== /* * KEY:商户支付密钥,参考开户邮件设置(必须配置,登录商户平台自行设置), 请妥善保管, 避免密钥泄露 * 设置地址:https://pay.weixin.qq.com/index.php/account/api_cert * * APPSECRET:公众帐号secert(仅JSAPI支付的时候需要配置, 登录公众平台,进入开发者中心可设置), 请妥善保管, 避免密钥泄露 * 获取地址:https://mp.weixin.qq.com/advanced/advanced?action=dev&t=advanced/dev&token=2005451881&lang=zh_CN * @var string */ public function GetKey() { return $this->set['apisecret']; } public function GetAppSecret() { return $this->set['secret']; } //=======【证书路径设置-需要业务方继承】===================================== /** * TODO:设置商户证书路径 * 证书路径,注意应该填写绝对路径(仅退款、撤销订单时需要,可登录商户平台下载, * API证书下载地址:https://pay.weixin.qq.com/index.php/account/api_cert,下载之前需要安装商户操作证书) * 注意: * 1.证书文件不能放在web服务器虚拟目录,应放在有访问权限控制的目录中,防止被他人下载; * 2.建议将证书文件名改为复杂且不容易猜测的文件名; * 3.商户服务器要做好病毒和木马防护工作,不被非法侵入者窃取证书文件。 * @var path * @var path */ public function GetSSLCertPath(&$sslCertPath, &$sslKeyPath) { $sslCertPath = $this->set['weixin_cert']; $sslKeyPath = $this->set['weixin_key']; } public function getCertPath() { return $this->set['weixin_cert']; } public function getKeyPath() { return $this->set['weixin_key']; } public $MaxQueryRetry = 12;//最大查询重试次数 public $QueryDuration = 5;//查询间隔 }