From 84f0a04aa3feaaeb994e64167a413c34b1ada3dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Wed, 19 May 2021 14:25:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4V3=E6=94=AF=E4=BB=98=E7=AD=BE?= =?UTF-8?q?=E5=90=8D=E5=8F=8AScript=E7=BC=93=E5=AD=98=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WeChat/Script.php | 2 +- WePayV3/Order.php | 4 ++-- _test/pay-v3-order-create.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/WeChat/Script.php b/WeChat/Script.php index 0a54b6b..c04be36 100644 --- a/WeChat/Script.php +++ b/WeChat/Script.php @@ -60,7 +60,7 @@ class Script extends BasicWeChat throw new InvalidResponseException('Invalid Resoponse Ticket.', '0'); } $ticket = $result['ticket']; - Tools::setCache($cache_name, $ticket, 5000); + Tools::setCache($cache_name, $ticket, 7000); } return $ticket; } diff --git a/WePayV3/Order.php b/WePayV3/Order.php index 460c995..355e2a7 100644 --- a/WePayV3/Order.php +++ b/WePayV3/Order.php @@ -60,10 +60,10 @@ class Order extends BasicWePay $prepayId = $result['prepay_id']; $nonceStr = Tools::createNoncestr(); if ($type === 'app') { - $sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, $prepayId])."\n"); + $sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, $prepayId, ''])); return ['partnerId' => $this->config['mch_id'], 'prepayId' => $prepayId, 'package' => 'Sign=WXPay', 'nonceStr' => $nonceStr, 'timeStamp' => $time, 'sign' => $sign]; } elseif ($type === 'jsapi') { - $sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, "prepay_id={$prepayId}"])."\n"); + $sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, "prepay_id={$prepayId}", ''])); return ['appId' => $appid, 'timeStamp' => $time, 'nonceStr' => $nonceStr, 'package' => "prepay_id={$prepayId}", 'signType' => 'RSA', 'paySign' => $sign]; } else { return $result; diff --git a/_test/pay-v3-order-create.php b/_test/pay-v3-order-create.php index db80007..5448b6a 100644 --- a/_test/pay-v3-order-create.php +++ b/_test/pay-v3-order-create.php @@ -14,10 +14,10 @@ try { 'appid' => 'wx60a43dd8161666d4', 'mchid' => $config['mch_id'], 'description' => '商品描述', - 'out_trade_no' => date("YmdHis"), + 'out_trade_no' => (string)time(), 'notify_url' => 'https://thinkadmin.top', 'payer' => ['openid' => 'o38gps3vNdCqaggFfrBRCRikwlWY'], - 'amount' => ['total' => 1, 'currency' => 'CNY'], + 'amount' => ['total' => 2, 'currency' => 'CNY'], ]); echo '
';