#swaroopnagothi25_api
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/1333504472370118752
๐ 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.
- swaroopnagothi25_api, 5 days ago, 74 messages
Hi ๐
Can you explain what you are doing?
Like, the validation errors should not destroy the payment element instance
Or do you mean you are passing invalid args to stripe.elements() when initializing without an intent?
I implemented payment element in my custom checkout page. In my checkout page, i can change my payment amount whenever i need. so initially my payment amount will be 0. as soon as i select the product in my checkout page, the payment amount will get updated.
In that case, you need to update the elements instance here: https://docs.stripe.com/js/elements_object/update
do i have to reload payment element as soon as there is a change to my payment amount?
this is happening when the payment amount is chnaged from 0 to some postive value.
That first error suggests that something in your front-end integration is destroying the Stripe element that has been created.
Are you using React?
yes
So in that case it's likely that React is destroying/recreating something in response to the user changing the amount. You should refactor your integration to avoid that.
sorry. i didn't get that can you give me an example?
Okay, when i see errors like this they are almost always due to how React handles reactivity. I'm not a React developer so I'm not super familiar with it but basically, you have your UI set to update when certain values change using a hook like useEffect . Part of that update destroys and recreates the Stripe <PaymentElement> or it's parent elements.
This means that, when something is updated on your site, you destroy the initialized Payment Element and your code cannot interact with it anymore
Hooo ok.
So for now, I am reintializing the payment element when there is a change to my payment amount.
Even I don't have much knowledge on react. But i think, it is not the right way to reinitialize the stripe each time.
Is there any one from your team can help to resolve the issue? if possible.
Hello, the recommended way to update amount would be to call elements.update and pass the new amount via the options param
https://docs.stripe.com/js/elements_object/update#elements_update-options-amount
That keeps the same elements instance but updates the amount that the payment element expects and passes to things like the Apple Pay payment sheet
It is mandatory if you are confirming the payment intent on the client side. The frontend needs to know which intent is being confirmed
The alternative would be to pass the PaymentMethod or ConfirmationToken ID back to your server and use it to confirm an intent there.https://docs.stripe.com/payments/finalize-payments-on-the-server
i added payment Element to component. and I am rendering it when there is change to my payment amount.
Here StripePaymentForm is my custom component and i have added paymentElement inside it.
paymentAmount && (<StripePaymentForm amount={paaymentAmount}/>)
and I am rendering it when there is change to my payment amount.
Not quite clear on what this means, can you tell me more about it? Calling that update call shouldn't require re-rendering components as far as I am aware.
And that null error should be similar to other null errors, you will want to double check whetherelementsis being unset somehow. Your code likely sets that variable at somepoint using theuseElementshook like in this doc https://docs.stripe.com/sdks/stripejs-react#useelements-hook
ook i will try this out. can you tell me how payment method configuartion works?
We have this helpful intro doc on them if you haven't seen them already. Basically you can have multiple automatic payment method selection configurations
https://docs.stripe.com/payments/payment-method-configurations
Is there a specific aspect of this behavior that you are trying to figure out?
if i create a payment intent with ``automatic_payment_methods = {enabled: true}
if a account has 5 payment method configurations. which one will pcik by the payment Inetnt
Your default configuration. There are defaults for Billing and non-Billing payments, to use a PMC other than those, you need to pass its ID https://dashboard.stripe.com/settings/payment_methods
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
if one stripe customer is connected to my ecommece site, then will there a new payment method configuration created?
To clarify, are you talking about a customer as in someone who is paying you? Or are you talking about someone with a Stripe account that is connected to your Stripe account? We typically call those "Customers" and "Accounts" respectively
about someone with a Stripe account that is connected to your Stripe account
That depends which connect charge flow you are using. If you are using a flow where the payment intent is created on your platform account, then it uses PMCs from your account. If you are using the direct charges flow where you create the intents on the connected account, or if you use on_behalf_of then it is a PMC that is on the connected account.
I think this doc will be helpful for you
https://docs.stripe.com/connect/dynamic-payment-methods
And my apologies, it looks like I was wrong. There is a PMC on your account that you can use to configure payment methods for direct charges that you make
https://dashboard.stripe.com/settings/payment_methods/connected_accounts
ok. this confihuration will get applied to all my connected accounts right.
Correct
so a connected account can have only one payment method configuration?
sorry, we can have, it give me a option to create a new configuration.
lets say if my connect account has 2 pmcs, then which one will be the parent to all my connected accounts?
Hello
taking over as pompey needs to step away soon
If you allow your connected accounts to manage their own payment methods via the dashboard then they might have different config as well. Otherwise, it should be just the one you create as a platform.
Do you mean via the dashboard or the API?
via the API, there's is_default param - https://docs.stripe.com/api/payment_method_configurations/object#payment_method_configuration_object-is_default
The dashboard adds a tag or something (don't remember 100%)
yeah
But when I make a get call it is showing all the configurations is_default aa true