Skip to content

Commit

Permalink
更新微信v2支付结果判断
Browse files Browse the repository at this point in the history
  • Loading branch information
pgyf committed Oct 12, 2022
1 parent 5ba311e commit c321c84
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/Pay/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

namespace Pgyf\Opensdk\Wechat\Pay;

use Pgyf\Opensdk\Kernel\Exceptions\InvalidArgumentException;
use Pgyf\Opensdk\Kernel\Exceptions\InvalidConfigException;
//use Pgyf\Opensdk\Kernel\Exceptions\InvalidArgumentException;
//use Pgyf\Opensdk\Kernel\Exceptions\InvalidConfigException;
use Pgyf\Opensdk\Kernel\HttpClient\HttpClientMethods;
use Pgyf\Opensdk\Kernel\HttpClient\RequestUtil;
use Pgyf\Opensdk\Kernel\HttpClient\RequestWithPresets;
use Pgyf\Opensdk\Kernel\HttpClient\Response;
use Pgyf\Opensdk\Kernel\Support\PrivateKey;
use Pgyf\Opensdk\Kernel\Support\PublicKey;
//use Pgyf\Opensdk\Kernel\Support\PrivateKey;
//use Pgyf\Opensdk\Kernel\Support\PublicKey;
use Pgyf\Opensdk\Kernel\Support\UserAgent;
use Pgyf\Opensdk\Kernel\Support\Xml;
use Pgyf\Opensdk\Kernel\Traits\MockableHttpClient;
//use Pgyf\Opensdk\Kernel\Traits\MockableHttpClient;
use Exception;
use function is_array;
use function is_string;
Expand Down Expand Up @@ -144,11 +144,18 @@ public function request(string $method, string $url, array $options = []): Respo
}

// 合并通过 withHeader 和 withHeaders 设置的信息
if (! empty($this->prependHeaders)) {
if (!empty($this->prependHeaders)) {
$options['headers'] = array_merge($this->prependHeaders, $options['headers'] ?? []);
}

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

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

0 comments on commit c321c84

Please sign in to comment.