Skip to content

Commit

Permalink
feat: 增加代理设置
Browse files Browse the repository at this point in the history
  • Loading branch information
qiqizjl committed Dec 30, 2019
1 parent 7e7667a commit 904d515
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/RestGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@

namespace Omnipay\PaypalV2;

use GuzzleHttp\Psr7\Request;
use Http\Adapter\Guzzle6\Client as GuzzleClient;
use Http\Discovery\HttpClientDiscovery;
use Omnipay\Common\AbstractGateway;
use Omnipay\Common\Http\Client;
use Omnipay\Common\Message\RequestInterface;
use Omnipay\Common\Message\ResponseInterface;
use Omnipay\PaypalV2\Message\Rest\CompletePurchaseRequest;
Expand Down Expand Up @@ -41,6 +45,25 @@ public function getDefaultParameters()
);
}

public function initialize(array $parameters = array ())
{
parent::initialize($parameters);
if (isset($parameters["http_proxy"])) {
$this->httpClient = $this->getClient($parameters["http_proxy"]);
}
}

protected function getClient($http_proxy)
{
$request = HttpClientDiscovery::find();
if ($request instanceof GuzzleClient) {
$request = GuzzleClient::createWithConfig([
"proxy" => $http_proxy,
]);
}
return new Client($request);
}


/**
* @inheritDoc
Expand Down

0 comments on commit 904d515

Please sign in to comment.