#kevin_code
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1400113741592395913
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello
Just to clarify, do you want to control the Payment Method Types via the dashboard OR do you want to explicitly specify the supported payment methods?
Hello, I want to specify clearly the supported payment methods when showing the iframe
Assuming you want to manually specify the payment method types based on ^^^, there are two ways you can integrate.
1/ You create a PaymentIntent/SetupIntent and use it's client-secret to render elements
- When you create a PaymentIntent/SetupIntent, you can specify the payment method types you want to support using
payment_method_typesparameter: https://docs.stripe.com/api/payment_intents/create#create_payment_intent-payment_method_types - When you use the client-secret associated with the Intent you created above, Elements will pull from the
payment_method_typesarray to show supported payment method types
2/ The other option is to use defer Intent flow which allows you to collect payment method details without creating an Intent first.
- In this flow, you'd specify the supported payment method types on the client-side using
paymentMethodTypesparameter: https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=payment#additional-options - Elements will render supported payment method types based on the above configuration.
- Once the details have been collected, you'd need to create an Intent server-side and specify the same
payment_method_types: https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=payment#create-intent
Oh okay thank you
Might be a dumb question but currently since my Elements is really high in my component tree, I should put this inside my screen instead of my root component?
Depends on your flow really.
Also depends on when do you want to intialize Stripe specific stuff in your app's lifecycle
Ah yes because I want to initialize on start but I can know the list of payment method types only really late in the funnel when the user added some prestations in the cart ๐
Sounds good! ๐
But if I add Elements on my screen, then Stripe will only initialize when the user arrives in the Recap screen where we show the cart and not when the app started, no? ๐ค
Not sure what you mean by that ๐
I don't know how your app is structured so I won't know what Recap screen is versus app's root screen
But to answer your question, Stripe.js will initialize wherever you're calling Stripe('PUBLISHABLE_KEY')
and loadStripe (if you're using React)
Oh sorry so I'm using react-router-dom
So I have my root component which is app.tsx that uses Elements and where I currently use loadStripe
But you're saying that I should add paymentMethodTypes inside Elements so that in the PaymentElement show the correct payment method types but I can only know this after the app initialized and after a request to my back-end server ๐ค
Hello my colleague has to step out soon but I can help. Catching up on this thread
Yep that would be the way to do it if you are manually specifying the payment method types. The alternative is automatic payment methods which is the dashboard setting mentioned earlier. It does sound like the dashboard settings could help simplify this a bit but I'm not sure of your constraints. Is there a specific reason you're preferring specifying the types yourself over using the automatic type selection?
Oh okay, yeah the dashboard would be a good compromise but it's complicated because where on the product where I work, we have really hard product conditions like "if the user select X or Y, we should show/hide paypal and if he's on X/Y country but has selected this product we can show PayPal" etc ๐
So it's okay if I use loadStripe and initialize Stripe really late in my funnel? ๐ค If yes, I'll try this and come back if I have any issue (or maybe contact you because I also need to do the migration on React Native as well)
And one last question before leaving, currently I'm using these Stripe versions
"@stripe/react-stripe-js": "~2.6.2",
"@stripe/stripe-js": "~3.0.10",
How do I know which JS stripe version match with which react-stripe-js version?
Ah gotcha, one thing I was hoping might help is that we do have settings for restricting payment method availability but I believe they only go as far as country and payment amount.
And yep, as long as you have the list of payment method types you want by the time you initialize the payment element component you should be good here
Oh okay really thanks, you've been really helpful ๐
Just one last question before closing this thread, is the last question about Stripe JS and Stripe React JS package compatibility, do you have a page where you say which @stripe/stripe-js version is compatible with which @stripe/react-stripe-js version?
Not sure if we do but I will ask my colleagues and get back with what we can find
Okay thanks a lot ๐
@atomic mauve we aren't seeing a page like that, I think you may have to go off of the package info. That said, a bit more context may help. Are you seeing errors or some other issue now when you try to install both at once?
Oh okay, TBH I don't encounter any issue ATM, it's because I'm preparing the migration project and I'm afraid of some incompatibilities when I'll migrate from @stripe/react-stripe-js 2.6.2 to 3.x and @stripe/stripe-js to 3.0.10 to 7.x ๐
Gotcha, we think that should work but would recommend testing it out first. Apologies for the delay, server got busy and I missed this thread for some time