Closed sfarkas1988 closed 4 years ago
@sfarkas1988 you can resolve your problem using Guzzle like this:
App\Payment\StripeService:
arguments:
$omnipayHttpClient: '@app.payment.omnipay_stripe_http_client'
app.payment.omnipay_stripe_http_client:
class: Omnipay\Common\Http\Client
public: true
arguments:
$httpClient: '@app.payment.stripe_guzzle_client'
app.payment.stripe_guzzle_client:
class: Http\Adapter\Guzzle6\Client
public: true
factory: ['Http\Adapter\Guzzle6\Client', 'createWithConfig']
arguments:
$config:
headers:
Stripe-Version: '%stripe_api_version%'
User-Agent: 'MyAppHttpClient/%server_hostname% Env/%kernel.environment% PHP/%php_version%'
http_errors: false
^ You need to set stripe_api_version
parameter in container (for example in parameters.yml or ".env" etc)
Maybe such solution should be mentioned in docs?
Ok, thx for the solution, but it should definitely be done much easier. In my view direclty here: \Omnipay\Stripe\Message\AbstractRequest::getHeaders
For anyone looking for walk around that can be made directly in code:
$paymentIntentsGateway = Omnipay::create(
'Stripe\PaymentIntents',
new \Omnipay\Common\Http\Client(
\Http\Adapter\Guzzle6\Client::createWithConfig(
[
'headers' => [
'Stripe-Version' => '2019-05-16',
],
]
)
)
);
I also want to agree with sfarkas1988 - this should be doable via omnipay gateway or request configuration.
I too would like to set the Stripe-Version in Omnipay to be able to check API version compatibility before switching the version in the Stripe control panel.
@Ezyweb-uk see this pull request https://github.com/thephpleague/omnipay-stripe/pull/136
@sfarkas1988 many thanks!
I'm trying to use the newest api version for stripe with your code base. I couldn't find a way on how to set the apiVersion within your code. What I did is I called the following method before calling any API method:
\Stripe\Stripe::setApiVersion("2019-05-16");
More infos: https://stripe.com/docs/api/versioningBut in the response header i.e of the authorize method, I get this:
Setting the apiVersion explicitly would be great.
Update:
\Omnipay\Stripe\Message\AbstractRequest::getHeaders is not setting the value as needed in this api doc: https://stripe.com/docs/api/versioning?lang=curl
I even couldn't find a way to set the version.