diff --git a/AmazonPay/Client.php b/AmazonPay/Client.php index 59c1cf1..54a401c 100644 --- a/AmazonPay/Client.php +++ b/AmazonPay/Client.php @@ -51,7 +51,9 @@ class Client implements ClientInterface, LoggerAwareInterface 'client_id' => null, 'app_id' => null, 'handle_throttle' => true, - 'override_service_url' => null + 'override_service_url' => null, + 'curl_connecttimeout' => 300, + 'curl_timeout' => 0 ); private $modePath = null; diff --git a/AmazonPay/HttpCurl.php b/AmazonPay/HttpCurl.php index 0fb0fdf..9210a61 100644 --- a/AmazonPay/HttpCurl.php +++ b/AmazonPay/HttpCurl.php @@ -56,6 +56,9 @@ protected function commonCurlParams($url,$userAgent) curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->config['curl_connecttimeout']); + curl_setopt($ch, CURLOPT_TIMEOUT, $this->config['curl_timeout']); + if (!is_null($this->config['cabundle_file'])) { curl_setopt($ch, CURLOPT_CAINFO, $this->config['cabundle_file']); } diff --git a/README.md b/README.md index af41be7..8ba082a 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,8 @@ composer require amzn/amazon-pay-sdk-php | Proxy Password | `proxy_password` | Default : `null` | | LWA Client ID | `client_id` | Default : `null` | | Handle Throttle | `handle_throttle` | Default : `true`
Other: `false` | +| Curl ConnectTimeout | `curl_connecttimeout` | Default : `300` | +| Curl Timeout | `curl_timeout` | Default : `0` | ## Setting Configuration diff --git a/tst/unit/ClientTest.php b/tst/unit/ClientTest.php index 1b117c5..a971876 100644 --- a/tst/unit/ClientTest.php +++ b/tst/unit/ClientTest.php @@ -21,7 +21,9 @@ class ClientTest extends \PHPUnit_Framework_TestCase 'proxy_host' => null, 'proxy_port' => -1, 'proxy_username' => null, - 'proxy_Password' => null + 'proxy_Password' => null, + 'curl_connecttimeout' => 300, + 'curl_timeout' => 0 ); public function testConfigArray()