#neil_code

1 messages ¡ Page 1 of 1 (latest)

wide domeBOT
#

👋 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/1319014607079211059

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

dull arch
#

Hello

#

An empty string should be the correct way to handle this update. Can you clarify more about what happens when you do that?

digital gorge
#

sure sure. When the empty string is set, but I have paymentMethodTypes set to ['card'] the Payment Element lets me choose both card and us bank account

dull arch
#

Hmm can you show me your full client-side code here?

digital gorge
#

yea sure, give me 2mins

#

ill send the code (just gotta remove all my crazy debugging), but incase this helps, this is what the context looks like:

#
if (
      elements &&
      currency &&
      currency.length > 0 &&
      amount &&
      amount > 0 &&
      customerSession &&
      styles
    ) {
      const paymentMethodTypes = [];
      if (paymentOptions.allowPaymentViaACH) {
        paymentMethodTypes.push('us_bank_account');
      }
      if (paymentOptions.allowPaymentViaCC) {
        paymentMethodTypes.push('card');
      }

      elements.update({
        currency: currency.toLowerCase(),
        paymentMethodTypes,
        amount,
        onBehalfOf: '',
        ...styles,
        customerSessionClientSecret: customerSession,
        setupFutureUsage: showSubscribeAction ? 'off_session' : null,
      });
      setIsOptionsUpdated(true);
    }
dull arch
#

Are you sure that paymentOptions.allowPaymentViaACH isn't true?

#

What happens if you just comment that out?

digital gorge
#

really sure, You can see that the Stripe Element context in react tree only has the paymentMethodType for 'card'

dull arch
#

Hmm okay let me test on my side, one moment.

#

Ah okay looks like I may be incorrect and you can't actually unset onBehalfOf here without re-rendering Payment Element.

digital gorge
#

ahh okay, that would make sense. Im sure i'll figure that out specific to my implementation, but any specific ideas that come to mind?

dull arch
#

You mean ideas in terms of how to handle this?

digital gorge
#

yea

#

your saying re-redner this right:

<PaymentElement
          options={{
            layout: differentialRatio > 1 ? 'tabs' : 'accordion',
            business: {
              name,
            },
            readOnly: isPaying,
          }}
          onChange={handlePaymentElementChange}
        />
dull arch
#

Easiest way is to use a key with your Elements component to force a re-render with the new options passed in.

digital gorge
#

Elements or PaymentElement haha?

dull arch
#

Elements, as that is what takes the options object where you specify onBehalfOf

#

That wraps your PaymentElement component

digital gorge
#

hmm... thats going to tear down the whole tree, and stripe docs suggest keeping the Element high up in the tree so we basically have it at root right now

#

can I render multiple Elements providers?

dull arch
#

Yes you should be able to

digital gorge
dull arch
#

I don't have a sample, sorry. While the recommendation is to wrap your whole tree with Elements, that isn't strictly necessary.