From bcf7cceb91a9bfabff365a1e2c1490e7658a007f Mon Sep 17 00:00:00 2001 From: voilaf <415545367@qq.com> Date: Wed, 2 Nov 2022 15:47:25 +0800 Subject: [PATCH] =?UTF-8?q?WechatPayV3=E5=92=8CAlipay=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E5=BA=94=E6=94=AF=E6=8C=81=E5=A4=96=E9=83=A8?= =?UTF-8?q?=E4=BC=A0=E5=85=A5=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WeChat/Contracts/BasicAliPay.php | 7 +++++-- WePayV3/Order.php | 11 ++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/WeChat/Contracts/BasicAliPay.php b/WeChat/Contracts/BasicAliPay.php index 04bd9a2..3793f6e 100644 --- a/WeChat/Contracts/BasicAliPay.php +++ b/WeChat/Contracts/BasicAliPay.php @@ -150,13 +150,16 @@ abstract class BasicAliPay /** * 获取通知数据 + * * @param boolean $needSignType 是否需要sign_type字段 + * @param array $parameters * @return array * @throws \WeChat\Exceptions\InvalidResponseException */ - public function notify($needSignType = false) + public function notify($needSignType = false, array $parameters = []) { - $data = $_POST; + $data = empty($parameters) ? $_POST : $parameters; + if (empty($data) || empty($data['sign'])) { throw new InvalidResponseException('Illegal push request.', 0, $data); } diff --git a/WePayV3/Order.php b/WePayV3/Order.php index 5108f1d..81dea53 100644 --- a/WePayV3/Order.php +++ b/WePayV3/Order.php @@ -86,10 +86,15 @@ class Order extends BasicWePay * @return array * @throws \WeChat\Exceptions\InvalidDecryptException */ - public function notify() + public function notify(array $parameters = []) { - $body = file_get_contents('php://input'); - $data = json_decode($body, true); + if (empty($parameters)) { + $body = file_get_contents('php://input'); + $data = json_decode($body, true); + } else { + $data = $parameters; + } + if (isset($data['resource'])) { $aes = new DecryptAes($this->config['mch_v3_key']); $data['result'] = $aes->decryptToString(