Update Order.php

微信要求:
签名串一共有四行,每一行为一个参数。行尾以\n(换行符,ASCII编码值为0x0A)结束,包括最后一行。
如果最后一行没有加\n,前端调起支付时会提签名错误。
This commit is contained in:
kentwangit 2021-04-29 16:18:22 +08:00 committed by GitHub
parent 4ba213dcea
commit d32b3ecd88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,10 +60,10 @@ class Order extends BasicWePay
$prepayId = $result['prepay_id']; $prepayId = $result['prepay_id'];
$nonceStr = Tools::createNoncestr(); $nonceStr = Tools::createNoncestr();
if ($type === 'app') { if ($type === 'app') {
$sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, $prepayId])); $sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, $prepayId])."\n");
return ['partnerId' => $this->config['mch_id'], 'prepayId' => $prepayId, 'package' => 'Sign=WXPay', 'nonceStr' => $nonceStr, 'timeStamp' => $time, 'sign' => $sign]; return ['partnerId' => $this->config['mch_id'], 'prepayId' => $prepayId, 'package' => 'Sign=WXPay', 'nonceStr' => $nonceStr, 'timeStamp' => $time, 'sign' => $sign];
} elseif ($type === 'jsapi') { } elseif ($type === 'jsapi') {
$sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, "prepay_id={$prepayId}"])); $sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, "prepay_id={$prepayId}"])."\n");
return ['appId' => $appid, 'timeStamp' => $time, 'nonceStr' => $nonceStr, 'package' => "prepay_id={$prepayId}", 'signType' => 'RSA', 'paySign' => $sign]; return ['appId' => $appid, 'timeStamp' => $time, 'nonceStr' => $nonceStr, 'package' => "prepay_id={$prepayId}", 'signType' => 'RSA', 'paySign' => $sign];
} else { } else {
return $result; return $result;