#neil_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/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.
- neil_api, 1 day ago, 14 messages
Hello
An empty string should be the correct way to handle this update. Can you clarify more about what happens when you do that?
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
Hmm can you show me your full client-side code here?
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);
}
Are you sure that paymentOptions.allowPaymentViaACH isn't true?
What happens if you just comment that out?
really sure, You can see that the Stripe Element context in react tree only has the paymentMethodType for 'card'
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.
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?
You mean ideas in terms of how to handle this?
yea
your saying re-redner this right:
<PaymentElement
options={{
layout: differentialRatio > 1 ? 'tabs' : 'accordion',
business: {
name,
},
readOnly: isPaying,
}}
onChange={handlePaymentElementChange}
/>
Easiest way is to use a key with your Elements component to force a re-render with the new options passed in.
Elements or PaymentElement haha?
Elements, as that is what takes the options object where you specify onBehalfOf
That wraps your PaymentElement component
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?
Yes you should be able to
do you have a code example of this? im just curious. I do have a fairly good grasp on react, but there is always some nuance to implementation and it seems like you have something working
I don't have a sample, sorry. While the recommendation is to wrap your whole tree with Elements, that isn't strictly necessary.