From e2847b50796285be60057f3ec5e5c8ee8914f1a7 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 26 Jun 2024 14:54:50 +0800 Subject: [PATCH] 1 --- extend/Wechat/WechatPay.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/extend/Wechat/WechatPay.php b/extend/Wechat/WechatPay.php index 8c318bf..89c8723 100644 --- a/extend/Wechat/WechatPay.php +++ b/extend/Wechat/WechatPay.php @@ -271,20 +271,21 @@ class WechatPay $url = "v3/pay/transactions/out-trade-no/" . $out_trade_no . "/close"; $response = $app->getClient()->postJson($url, $options); - if ($response->isFailed()) { - // 出错了,处理异常 - $result = $response->toArray(false); - Log::getInstance()->info(json_encode($result,JSON_UNESCAPED_UNICODE)); - if(empty($result)){ - // 返回值为空 - throw new BusinessException("发起支付失败"); - } - if (!empty($result['code'])){ - if ($result['code'] != 400){ - throw new BusinessException($result['message']); + if (!empty($response)){ + if ($response->isFailed()) { + // 出错了,处理异常 + $result = $response->toArray(false); + if(empty($result)){ + // 返回值为空 + throw new BusinessException("关闭支付订单失败"); + } + if (!empty($result['code'])){ + if ($result['code'] != 400){ + throw new BusinessException($result['message']); + } + }else{ + throw new BusinessException("关闭支付订单失败"); } - }else{ - throw new BusinessException("关闭支付订单失败"); } }