[更新]修改企业打款签名参数

This commit is contained in:
Cxphp 2018-04-09 18:55:25 +08:00 committed by Anyon
parent 9ba300d0b1
commit cccd44dad5

View File

@ -196,7 +196,7 @@ class Pay
public function createTransfers(array $options) public function createTransfers(array $options)
{ {
$url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers'; $url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers';
return $this->callPostApi($url, $options, true); return $this->callPostApi($url, $options, true, false);
} }
/** /**
@ -208,7 +208,7 @@ class Pay
public function queryTransfers($partner_trade_no) public function queryTransfers($partner_trade_no)
{ {
$url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo'; $url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo';
return $this->callPostApi($url, ['partner_trade_no' => $partner_trade_no], true); return $this->callPostApi($url, ['partner_trade_no' => $partner_trade_no], true, false);
} }
/** /**
@ -248,10 +248,11 @@ class Pay
* @param string $url 请求 * @param string $url 请求
* @param array $data 接口参数 * @param array $data 接口参数
* @param bool $isCert 是否需要使用双向证书 * @param bool $isCert 是否需要使用双向证书
* @param bool $needSignType 是否需要传签名类型参数
* @return array * @return array
* @throws InvalidResponseException * @throws InvalidResponseException
*/ */
public function callPostApi($url, array $data, $isCert = false) public function callPostApi($url, array $data, $isCert = false, $needSignType = true)
{ {
$option = []; $option = [];
if ($isCert) { if ($isCert) {
@ -264,7 +265,9 @@ class Pay
$option['ssl_key'] = $this->config->get('ssl_key'); $option['ssl_key'] = $this->config->get('ssl_key');
} }
$params = $this->params->merge($data); $params = $this->params->merge($data);
if ($needSignType) {
$params['sign_type'] = 'HMAC-SHA256'; $params['sign_type'] = 'HMAC-SHA256';
}
$params['sign'] = $this->getPaySign($params); $params['sign'] = $this->getPaySign($params);
$result = Tools::xml2arr(Tools::post($url, Tools::arr2xml($params), $option)); $result = Tools::xml2arr(Tools::post($url, Tools::arr2xml($params), $option));
if ($result['return_code'] !== 'SUCCESS') { if ($result['return_code'] !== 'SUCCESS') {