/** * 将xml转为array * @param string $xml * @throws Exception */ public static function Init($xml, API $api) { WechatLog::create(['log' => $xml, 'waid' => $api->waid, 'url' => app('url')->full()]); $obj = new self(); $obj->fromXml($xml); //fix bug 2015-06-29 if ($obj->values['return_code'] == 'SUCCESS') { $obj->CheckSign($api->mchkey); } return $obj->getValues(); }
public function setConfig($options, $waid) { $this->waid = $waid; $this->token = $options['token'] ?: ''; $this->encodingAesKey = $options['encodingaeskey'] ?: ''; $this->appid = $options['appid'] ?: ''; $this->appsecret = $options['appsecret'] ?: ''; $this->debug = @$options['debug'] ?: true; $this->logcallback = @$options['logcallback'] ?: function ($api, $log, $url = NULL) { WechatLog::create(['log' => $log, 'waid' => $api->waid, 'url' => $url ?: app('url')->full()]); }; //支付信息 $this->mchid = $options['mchid'] ?: ''; $this->mchkey = $options['mchkey'] ?: ''; $this->sub_mch_id = $options['sub_mch_id'] ?: ''; $this->sslcert_path = @$options['sslcert_path'] ?: app_path('certs/' . $this->appid . '/apiclient_cert.pem'); $this->sslkey_path = @$options['sslkey_path'] ?: app_path('certs/' . $this->appid . '/apiclient_key.pem'); }