From 0c01bd07614027c5dee1e75069a5351c7cbacbd3 Mon Sep 17 00:00:00 2001 From: Anyon Date: Thu, 24 Dec 2020 16:40:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=80=80=E6=AC=BE=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WePay/Refund.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/WePay/Refund.php b/WePay/Refund.php index 16e977d..39ac36a 100644 --- a/WePay/Refund.php +++ b/WePay/Refund.php @@ -16,6 +16,7 @@ namespace WePay; use WeChat\Contracts\BasicWePay; use WeChat\Contracts\Tools; +use WeChat\Exceptions\InvalidDecryptException; use WeChat\Exceptions\InvalidResponseException; /** @@ -55,6 +56,7 @@ class Refund extends BasicWePay /** * 获取退款通知 * @return array + * @throws InvalidDecryptException * @throws InvalidResponseException */ public function getNotify() @@ -63,11 +65,14 @@ class Refund extends BasicWePay if (!isset($data['return_code']) || $data['return_code'] !== 'SUCCESS') { throw new InvalidResponseException('获取退款通知XML失败!'); } - $key = md5($this->config->get('mch_key')); - $decrypt = base64_decode($data['req_info']); - $response = openssl_decrypt($decrypt, 'aes-256-ecb', $key, OPENSSL_RAW_DATA); - $data['result'] = Tools::xml2arr($response); - return $data; + try { + $key = md5($this->config->get('mch_key')); + $decrypt = base64_decode($data['req_info']); + $response = openssl_decrypt($decrypt, 'aes-256-ecb', $key, OPENSSL_RAW_DATA); + $data['result'] = Tools::xml2arr($response); + return $data; + } catch (\Exception $exception) { + throw new InvalidDecryptException($exception->getMessage(), $exception->getCode()); + } } - } \ No newline at end of file