diff --git a/README.md b/README.md index 2abfa0c..610ef57 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ $init = new \PagOnline\Init\IgfsCgInit(); $init->serverURL = "https://payment-gateway-example.com/IGFS_CG_SERVICES/services"; $init->tid = "MY-TID-CODE"; $init->kSig = '1234567890987654321'; -$init->timeout = 15000; $init->shopID = 'my-transaction-id'; $init->shopUserRef = "email@example.org"; $init->trType = "AUTH"; @@ -31,6 +30,13 @@ $init->notifyURL = "http://my-domain.tld/verify.php"; $init->errorURL = "http://my-domain.tld/error.php"; $init->addInfo1 = 'myFirstAddintionalInfo'; +// if you need to edit http client parameters... +$init->setRequestTimeout(10); // Seconds +$init->setConnectTimeout(5); // Seconds +$init->setHttpProxy('tcp://some.proxy'); // Proxy server for requests +$init->setHttpAuthUser('username'); // HTTP Basic Auth username +$init->setHttpAuthPass('password'); // HTTP Basic Auth password + if (!$init->execute()) { // Something went wrong } else { @@ -48,7 +54,8 @@ to copy `pagonline.php` config file Set the following environment variables in your `.env` file: - `PAGONLINE_SERVER_URL` payment gateway server url (_default: null_) -- `PAGONLINE_TIMEOUT` maximum timeout in milliseconds for completing a request (_default: 15000_) +- `PAGONLINE_REQUEST_TIMEOUT` maximum timeout in seconds for completing a request (_default: 15_) +- `PAGONLINE_CONNECT_TIMEOUT` maximum timeout in seconds for connecting to the server (_default: 5_) - `PAGONLINE_TERMINAL_ID` identifier provided by the payment gateway (_default: null_) - `PAGONLINE_SIGNATURE_KEY` signature key provided by the payment gateway (_default: null_) - `PAGONLINE_CURRENCY_CODE` currency code (_default: EUR_) diff --git a/config/pagonline.php b/config/pagonline.php index 7553d6c..0237f3c 100644 --- a/config/pagonline.php +++ b/config/pagonline.php @@ -2,7 +2,13 @@ return [ 'server_url' => env('PAGONLINE_SERVER_URL', null), - 'timeout' => env('PAGONLINE_TIMEOUT', 15000), + 'request_timeout' => env('PAGONLINE_REQUEST_TIMEOUT', 15), + 'connect_timeout' => env('PAGONLINE_CONNECT_TIMEOUT', 5), + + 'http_proxy' => env('PAGONLINE_HTTP_PROXY', ''), + 'http_basic_auth_user' => env('PAGONLINE_HTTP_BASIC_AUTH_USER', ''), + 'http_basic_auth_pass' => env('PAGONLINE_HTTP_BASIC_AUTH_PASS', ''), + // tid 'terminal_id' => env('PAGONLINE_TERMINAL_ID', null), // kSig diff --git a/src/IgfsCgFactory.php b/src/IgfsCgFactory.php index 491a9fb..d500e9d 100644 --- a/src/IgfsCgFactory.php +++ b/src/IgfsCgFactory.php @@ -36,7 +36,12 @@ public static function make(string $namespace): IgfsCgInterface $igfsCgClass->currencyCode = Config::get('pagonline.currency_code'); $igfsCgClass->langID = Config::get('pagonline.language_id'); - $igfsCgClass->setRequestTimeout((int) Config::get('pagonline.timeout')); + // HTTP configuration + $igfsCgClass->setRequestTimeout((int) Config::get('pagonline.request_timeout')); + $igfsCgClass->setConnectTimeout((int) Config::get('pagonline.connect_timeout')); + $igfsCgClass->setHttpProxy(Config::get('pagonline.http_proxy')); + $igfsCgClass->setHttpAuthUser(Config::get('pagonline.http_basic_auth_user')); + $igfsCgClass->setHttpAuthUser(Config::get('pagonline.http_basic_auth_pass')); } return $igfsCgClass; diff --git a/src/Traits/HttpClient.php b/src/Traits/HttpClient.php index 59d3074..45766c2 100644 --- a/src/Traits/HttpClient.php +++ b/src/Traits/HttpClient.php @@ -32,17 +32,17 @@ trait HttpClient /** * @var string */ - protected $httpAuthUser; + protected $httpAuthUser = ''; /** * @var string */ - protected $httpAuthPass; + protected $httpAuthPass = ''; /** * @var string */ - protected $httpProxy; + protected $httpProxy = ''; /** * @param array $configuration