Skip to content

Commit

Permalink
Merge pull request #26 from giantwu/master
Browse files Browse the repository at this point in the history
修改签名方法,拼接xml时默认 使用cdata。用来消除特殊字符对xml的影响
  • Loading branch information
kiss291323003 authored Sep 3, 2019
2 parents 040b5a5 + 2fd6107 commit 0a5c9a6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/WeChat/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ public function generateSign(array $data): string
*/
private function getSignContent(array $data): string
{
return urldecode(http_build_query($data));
/*
$buff = '';
foreach ($data as $k => $v) {
$buff .= ($k != 'sign' && $v != '' && !is_array($v)) ? $k . '=' . $v . '&' : '';
}
return trim($buff, '&');
*/
}

/**
Expand Down Expand Up @@ -94,7 +97,7 @@ public function request(string $endpoint, Base $bean, bool $useCert = false): st
$bean->setAppId($bean instanceof \EasySwoole\Pay\WeChat\RequestBean\MiniProgram ? $this->config->getMiniAppId() : $this->config->getAppId());
$bean->setMchId($this->config->getMchId());
$bean->setSign($this->generateSign($bean->toArray()));
$response = NewWork::postXML($this->config->getGateWay() . $endpoint, (new SplArray($bean->toArray()))->toXML(), $useCert ? [
$response = NewWork::postXML($this->config->getGateWay() . $endpoint, (new SplArray($bean->toArray()))->toXML(true), $useCert ? [
'ssl_cert_file' => $this->config->getApiClientCert(),
'ssl_key_file' => $this->config->getApiClientKey()]
: []);
Expand Down

0 comments on commit 0a5c9a6

Please sign in to comment.