stripe-archive / react-stripe-elements

Moved to stripe/react-stripe-js.
https://github.com/stripe/react-stripe-js
MIT License
3.03k stars 319 forks source link

Change Stripe API Version #516

Closed epintos closed 4 years ago

epintos commented 4 years ago

Is it possible to change the Stripe API version to a specific version as suggested here with the Stripe-Version header?

epintos commented 4 years ago

I just saw here that is possible to add it as a parameter to the Stripe object. Is there another way?

hofman-stripe commented 4 years ago

@epintos, what other way are you looking for? As you've discovered, you can create a stripe object with a specific apiVersion, and use it with react-stripe-elements.

epintos commented 4 years ago

@hofman-stripe Yes, that is already a good solution for me, but I was also thinking about a configuration file where you add the Stripe API Version that you want. So the version is outside of the code.

hofman-stripe commented 4 years ago

Unless I'm not understanding something, that would have to be something that depends on the tooling and framework you use, not something this or any of our library can provide.

When not specifying an API Version, the default version configured for your account will be used. That's the only external configuration possible.

I'm going to close this issue since this is not related to these React bindings. Stripe Support should be able to help you with any general question regarding your integration.

maxjacobson commented 4 years ago

Hi there!

I stumbled on this issue, because I was looking to do the same thing. Sharing this in case it's helpful to anyone else.

I had:

<StripeProvider apiKey={apiKey}>

I was about to change it to:

const stripe = Stripe(apiKey, { apiVersion: '2019-12-03' });

<StripeProvider stripe={stripe}>

When I looked at the source code, which suggests that this will work just fine, and it's a smaller diff, which I like:

<StripeProvider apiKey={apiKey} apiVersion={'2019-12-03'}>

If I'm right that this is a supported way to use the library, I think it would make sense to include an example about this in the docs. Apologies if it's there and I missed it :)