thephpleague / omnipay-common

Core components for the Omnipay PHP payment processing library
MIT License
329 stars 242 forks source link

Migrating Gateway to v3 - how to set http timeout and enforcing TLS1.2 #195

Open funkflute opened 6 years ago

funkflute commented 6 years ago

So the new default PSR-7 interface doesn't seem to allow options I was using when were using Guzzle:

CURLOPT_SSLVERSION     => CURL_SSLVERSION_TLSv1_2,
CURLOPT_CONNECTTIMEOUT => 10,

So should I be requiring guzzle and implementing it in my gateway? (how would I register it as the default $this->httpClient?) Or is there another preferred way to get these types of options I'm not seeing?

Also is there a way to disable the "MockClient" during PhpUnit Testing and use the real HttpClient? This is so I can test that the actual HTTP connection process is getting data back as it should.

judgej commented 6 years ago

Had the same problem myself the other day. I wanted to switch on Guzzle debug, but httplug does not provide a way to add options, the reasoning being that options vary so much between different HTTP implementations.

I think the way to do this is to create an extended Guzzle client, with your own injected options, and register that with httplug. I only got as far as the concept and could not find any decent examples to follow. When it is worked out, I think a package containing the extension will be useful. I'm not sure that a Omnipay driver could ever add its own options, since it does not know what implementation is being used, but perhaps a separate package could contain enough specific logic to know how to pass some common options to most popular HTTP client implementations at least.