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