#naren_api

1 messages ¡ Page 1 of 1 (latest)

placid bloomBOT
#

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

📝 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.

gilded glacier
#

i asked the same question yesterday but i wasn't able to text. i had to contact stripe support

#

current code

merry cedarBOT
thick yew
#

After initialising payment sheet, you will need to open the payment sheet to reflect the new value

#

If you create the Payment Intent every time, it will hit rate limit very fast: https://docs.stripe.com/rate-limits

I'd recommend using deferred intent flow which will delay creating the payment intent until the amount is finalised: https://docs.stripe.com/payments/accept-a-payment-deferred?platform=react-native&type=payment

Learn about API rate limits and how to work with them.

Build an integration where you can render the Payment Element prior to creating a PaymentIntent or SetupIntent.

gilded glacier
thick yew
#

I don't see you updating the amount in intentConfiguration when there is an amount change. confirmHandler will only be called when the user clicks the the payment button in Payment Sheet

gilded glacier
#

i just tried this and the currency hasn't changed

thick yew
#

Where do you let the customer change the amount? You should update the amount in intentConfiguration in initializePaymentSheet when there is an amount change, and open the payment sheet again

gilded glacier
#

ultimately, before the checkout button is clicked and openpaymentsheet is called, i update amount and currency with the right values. in this case, i just updated them to random values in the openpaymentsheet function (right before presenting the payment sheet)

#

i changed the code so that amount and currencyCode in intentconfig uses the useState variables (which i update right before click)

thick yew
#

The amount should be updated in both the intentConfiguration in initializePaymentSheet and the amount in confirmHandler

gilded glacier
#

in this code, it is, right?

thick yew
#

This is not right. When there is a amount change, you should call the initializePaymentSheet before open the payment sheet. The setAmount and setCurrency should be done at where you detect these value changes, and initialise payment sheet again

#

You shouldn't set setAmount and setCurrency in open payment sheet since the initializePaymentSheet has been called with the old value

gilded glacier
#

oh. but once i set amount and currency, shouldn't the useeffect hook call initializepaymentsheet with the new values?

#

where shoudl i set amount/currency then? i'm confused

thick yew
#

In your useEffect, you didn't set amount or currency as the dependency

gilded glacier
#

oh ok. i'll set the dependecy to currency since it's the last updated. will this be the only fix?

thick yew
#

where shoudl i set amount/currency then?
You should have a change callback in your amount input to set the amount and currency

#

i'll set the dependecy to currency since it's the last updated. will this be the only fix?
In addition, you should also setAmount and setCurrency in the change input of your UI, not in open payment sheet

placid bloomBOT
gilded glacier