Skip to content

Commit

Permalink
更新微信支付结果状态判断条件 (#2600)
Browse files Browse the repository at this point in the history
* 更新微信支付结果状态判断条件

目前的版本只用微信支付接口时,`$response->isSuccessful()` 方法无法返回正确的值,接口请求成功但业务状态错误时,依然为true。
我用这个方法做的判断,看日志都成功了,下午一身冷汗。

* 优化 返回值处理
  • Loading branch information
bangbangda committed Oct 11, 2022
1 parent b8c537d commit 06c1094
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Pay/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ public function request(string $method, string $url, array $options = []): Respo
$options['headers'] = array_merge($this->prependHeaders, $options['headers'] ?? []);
}

return new Response($this->client->request($method, $url, $options), throw: $this->throw);

return new Response(
$this->client->request($method, $url, $options),
failureJudge: $this->isV3Request($url) ? null : fn (Response $response) => $response->toArray()['result_code'] === 'FAIL' || $response->toArray()['return_code'] === 'FAIL',
throw: $this->throw
);
}

protected function isV3Request(string $url): bool
Expand Down

1 comment on commit 06c1094

@vercel
Copy link

@vercel vercel bot commented on 06c1094 Oct 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

easywechat – ./

easywechat-git-6x-overtrue.vercel.app
easywechat.vercel.app
easywechat-overtrue.vercel.app

Please sign in to comment.