#zhucchiniii

1 messages ยท Page 1 of 1 (latest)

wispy pondBOT
heady root
#

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

half skiff
#

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? ๐Ÿ˜ฎ

heady root
#

Not sure I understand

#

Can't you just explicitly pass the payment method types you want to accept for the different flows?

half skiff
#

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? ๐Ÿ˜ฎ

heady root
#

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

half skiff
#

That's correct!

#

I see - we're using setup intents though and I don't think I see a currency option when creating one

wispy pondBOT
maiden anvil
#

Hello! I'm taking over and catching up...

#

I'm not sure if the Payment Element will take that into account though.

half skiff
#

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

maiden anvil
#

So you can call element.update() to change the order when the currency changes.

half skiff
#

Does paymentMethodOrder affect only the order of the payment methods or also the payment methods that are shown?

maiden anvil
#

Not sure I understand, can you provide more detail?

half skiff
#

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

maiden anvil
#

Ah, no, it doesn't hide them, it just changes the order they're displayed in.

half skiff
#

Gotcha

maiden anvil
#

If you want to change them you need to modify the underlying Setup Intent's payment methods.

half skiff
#

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)

maiden anvil
#

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.

half skiff
#

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

maiden anvil
#

It should do that, yep.

half skiff
#

But it doesn't seem to do that

maiden anvil
#

What do you mean?

half skiff
#

Sorry, when you say

It should do that
Do you mean with only the automatic_payment_methods option or also with the payment_method_types array?

#

Because it doesn't seem to work with payment_method_types array on the setup intent

maiden anvil
half skiff
#

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?

maiden anvil
#

Not sure I understand, why would you need to keep that mapping?

half skiff
#

So that we can dynamically change the payment_method_types array based on the user's currency selection

half skiff
#

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)

maiden anvil
half skiff
#

I see, so for payment intents, Stripe does support filtering payment_method_types based on currency, but not on setup intents? ๐Ÿ˜ฎ

half skiff
maiden anvil
#

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.

half skiff
#

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?

maiden anvil
#

Instead of using the Setup Intent to initialize the Payment Element have you considered... not doing that?

half skiff
#

hahaha

#

Honestly I thought that was the only option ๐Ÿ˜ฎ

maiden anvil
#

Like when you call stripe.elements() don't provide a client secret there. Instead specify the other options.

half skiff
#

Outside of using Payment Intents, which wasn't something we could do

maiden anvil
#

You would set the mode to setup and the currency to whatever and it should work the way you want, I think.

half skiff
#

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

maiden anvil
#

It's a newish flow, so it may not have been around depending on when you started working on this.

half skiff
#

Oh no wonder, that makes sense

#

Okay, sorry, just to make I understand this correctly - the new flow would look something like:

  1. Initialize elements with a mode and a currency
  2. Just before confirmSetup, create a new Setup Intent to pass into confirmSetup

and everything else stays the same?

maiden anvil
#

I can't say for certain that everything else stays the same as I'm not that familiar with your integration, but possibly yes.

half skiff
#

No worries, I'll test this out!! Thanks!!

maiden anvil
#

Happy to help!

half skiff
#

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

maiden anvil
#

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.

half skiff
#

got it, so it's the same issue

#

Since we still want to specific paymentMethodTypes in order to customize payment methods for each flow

maiden anvil
#

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.

half skiff
#

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?

maiden anvil
#

There's always a chance, but if we do it won't be in the near future as far as I know.

half skiff
#

Gotcha, that's helpful

#

Thanks again!