#zhucchiniii
1 messages ยท Page 1 of 1 (latest)
This is expected behavior. Whatever payment methods are directly passed to the SetupIntent/PaymentIntent always take priority
So if you explicitly pass payment methods instead of using automatic payment methods, then those are what will always be used
Gotcha. We were hoping that the currency would override the payment_method_types passed because some of our checkout flows support different payment methods, but from what I understand automatic_payment_methods doesn't support that use case. Do you have any recommendations for how to approach this? ๐ฎ
Not sure I understand
Can't you just explicitly pass the payment method types you want to accept for the different flows?
Ah sorry, I meant to add that we also want the payment element to dynamically change payment methods based on the currencies in each flow
But if the payment methods that Stripe renders in the payment element is dependent on what's enabled in our Stripe dashboard, my impression is that we wont' be able to customize payment methods per flow AND have payment methods display depending on the currency when initializing Stripe elements - is this correct? ๐ฎ
So just to clarify, you want the currency param to essentially filter the payment methods passed into the payment_method_types array?
You might have to set currency on the actual payment intent to do that
That's correct!
I see - we're using setup intents though and I don't think I see a currency option when creating one
Hello! I'm taking over and catching up...
You can set a currency in the mandate options on a Setup Intent for some payment methods, like this one for cards for example: https://stripe.com/docs/api/setup_intents/create#create_setup_intent-payment_method_options-card-mandate_options-currency
I'm not sure if the Payment Element will take that into account though.
You can specify a specific paymentMethodOrder though: https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-paymentMethodOrder
Gotcha, yeah - another wrinkle in this is that we also allow users to change their currency while on the payment input page as well, so we'd want the payment element to update with their newly selected currencies
I think we'll definitely make use of the paymentMethodOrder, but we're still hoping that the payment element can dynamically show / hide payment methods based on currency, regardless of how the setup intent was created ๐ฎ
Otherwise we'll have to either show an error when they change their currency to a payment method that doesn't support said currency, which isn't something that we'd like to own, or limit the payment methods in our dashboard to be the overlapping payment methods between our 2 flows, which is also not ideal
You can update paymentMethodOrder on an existing Payment Element: https://stripe.com/docs/js/elements_object/update_payment_element#payment_element_update-options-paymentMethodOrder
So you can call element.update() to change the order when the currency changes.
Does paymentMethodOrder affect only the order of the payment methods or also the payment methods that are shown?
Not sure I understand, can you provide more detail?
Oh yeah - paymentMethodOrder would help us order the payment methods in the way we want, but we want to be able to dictate which payment methods are shown in any given flow (which may be different based on flow), and have them dynamically change based on the currency passed
If paymentMethodOrder ends up hiding the payment methods not passed, then we can probably keep a list on our side to hide specific payment methods dependent on flow, which isn't necessarily ideal but it'd work for our use case
Ah, no, it doesn't hide them, it just changes the order they're displayed in.
Gotcha
If you want to change them you need to modify the underlying Setup Intent's payment methods.
I see, that's unfortunate :/
Do you happen to know why currency doesn't override the list in payment_method_types?
Our example use case is: we want flow A to support only cards and SEPA, and flow B to support only cards and we chat pay
If we use automatic_payment_methods, flow A would also show we chat pay, and flow B would would also show SEPA, which isn't what we want.
And in both cases, we want flows to only show payment methods relevant to the user's currency (e.g. SEPA would only show for EUR)
We automatically filter out payment methods that aren't compatible with the currency specified, but as you mentioned there is no currency on Setup Intents, so you would need to handle this logic manually on your end. I recommend you figure out the currency before you create the Setup Intent or render the Payment Element so you don't have to update it over and over as that changes.
I see, but we're specifying a currency when initializing Stripe elements so we thought that that currency parameter would be enough to override the payment methods in the payment element ๐ฎ
We're fine with repeatedly calling elements.update() with the new currency to update the payment methods if it does filter out the payment methods specified in the setup intent
It should do that, yep.
But it doesn't seem to do that
What do you mean?
Sorry, when you say
It should do that
Do you mean with only theautomatic_payment_methodsoption or also with thepayment_method_typesarray?
Because it doesn't seem to work with payment_method_types array on the setup intent
But from this documentation (https://stripe.com/docs/payments/customize-payment-methods#enable-different-payment-methods) we were under the impression it would ๐ฎ
If you update the payment_method_types on the Setup Intent and then call elements.fetchUpdates() it should pick up those changes: https://stripe.com/docs/js/elements_object/fetch_updates
I see, and in that case we'd have to manually maintain a mapping of currency: acceptable payment method types for currency on our own end?
Is there any mapping from Stripe we can use instead?
Not sure I understand, why would you need to keep that mapping?
So that we can dynamically change the payment_method_types array based on the user's currency selection
In this scenario where we still want to allow users to update their currency while on the payment form
Since it seems like Stripe doesn't support filtering payment methods out based on currency and payment_method_types, it sounds like we'll have to do that ourselves and call elements.fetchUpdates, but we'd rather not maintain a list of acceptable payment methods for each currency on our own end (esp if that somehow falls out of sync with what Stripe actually supports)
We do on Payment Intents, but yeah I see what you're saying. You can look at the docs here for a mapping: https://stripe.com/docs/payments/payment-methods/integration-options#country-currency-support
I see, so for payment intents, Stripe does support filtering payment_method_types based on currency, but not on setup intents? ๐ฎ
Does this exist somewhere in your Ruby package? ๐
Yeah, there's no top-level currency property on a Setup Intent because there's no money being moved; you're only setting up the payment details for future use.
For Payment Intents there is a currency because money is being moved, so we filter based on that so only payment methods that can actually be used for the payment are shown.
The mapping does not exist in the Ruby library, no.
Gotcha - unfortunately only Setup Intents work for our use case because our subscription creation is a little complicated ๐
Is there any world where Stripe could support filtering payment methods using the currency passed into Stripe.elements while using the payment_method_types on a Setup Intent?
Instead of using the Setup Intent to initialize the Payment Element have you considered... not doing that?
Like when you call stripe.elements() don't provide a client secret there. Instead specify the other options.
Outside of using Payment Intents, which wasn't something we could do
Basically it would be a variant on this: https://stripe.com/docs/payments/accept-a-payment-deferred?platform=web&type=setup
You would set the mode to setup and the currency to whatever and it should work the way you want, I think.
Interesting, I'll give this a shot! I remember when I first went through all the documentation I think the recommendation was to always pass a clientSecret so I hadn't realized this would be an option
It's a newish flow, so it may not have been around depending on when you started working on this.
Oh no wonder, that makes sense
Okay, sorry, just to make I understand this correctly - the new flow would look something like:
- Initialize
elementswith amodeand acurrency - Just before
confirmSetup, create a new Setup Intent to pass intoconfirmSetup
and everything else stays the same?
I can't say for certain that everything else stays the same as I'm not that familiar with your integration, but possibly yes.
No worries, I'll test this out!! Thanks!!
Happy to help!
Hi, sorry, I'm back - I tried it out and it seems like I'm having the same issue where the payment methods aren't updating based on the currency selected
GIF (hopefully) attached
It seems like Stripe recognizes that sepa_debit isn't a valid payment method to pass in for the USD currency, but throws an error instead of updating the payment methods to reflect the error
const _elements = stripe.elements({
mode: 'setup',
currency: props.currency,
paymentMethodTypes: ['card', 'sepa_debit'],
...stripeElementStyles,
})
The code for initializing stripe elements
You would need to use automatic payment methods if you want them to be automatically filtered out based on currency.
Insstead of specifying payment_method_types I mean.
got it, so it's the same issue
Since we still want to specific paymentMethodTypes in order to customize payment methods for each flow
Yes, the alternative is to modify the payment method types you specify based on the currency selection. This approach means you can do that completley client-side though, which is better than doing the Setup Intent update.
Gotcha, that's fair!
Sorry to be such a nag, but just to confirm one more time - there's no chance that Stripe will handle this functionality for setup intents?
There's always a chance, but if we do it won't be in the near future as far as I know.