333
This commit is contained in:
parent
347f5d2891
commit
7839cbe073
@ -254,11 +254,10 @@ class WechatPay
|
||||
/**
|
||||
* 关闭订单
|
||||
* @param string $out_trade_no 商户系统内部订单号
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function closeOrder(string $out_trade_no): array
|
||||
public function closeOrder(string $out_trade_no): void
|
||||
{
|
||||
$app = $this->createApp();
|
||||
|
||||
@ -270,27 +269,8 @@ class WechatPay
|
||||
try {
|
||||
$url = "v3/pay/transactions/out-trade-no/" . $out_trade_no . "/close";
|
||||
|
||||
$response = $app->getClient()->postJson($url, $options);
|
||||
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("关闭支付订单失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $response->toArray(false);
|
||||
} catch (\Exception $e) {
|
||||
$app->getClient()->postJson($url, $options);
|
||||
} catch (\Throwable $e) {
|
||||
throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user