#Tony Thomas-react

1 messages · Page 1 of 1 (latest)

crisp thistle
#

Hi there! Let me copy-paste all your messages in this thread:

So that it would look like: Pay 200 USD now.
I see the stripe.retrievePaymentIntent(clientSecret).then({}) // block, but apparently this is not called on the page load \

#

So you are creating a PaymentIntent for 200 USD, and you would like to show that amount on the page?

mint kite
#

In this case, we have the payment intent created at the backend, so the client do not have access to the amount data straight away.

#

But, you are right. We are creating a 200 USD payment intent at the backend, and the checkout page has the payment intent secret as a URL param. We use this link as a customer support tool in case we have payment failures.

crisp thistle
#

I think the simplest solution would be to edit your backend to return the clientSecret and the paymentIntent.amount. Then you can display that information on your frontend. Otherwise you could also call retrievePaymentIntent(clientSecret) on the frontend.

mint kite
#

So I have a gist here, which should work as expected, I guess. (lines 32-33) . However, if I understand this correctly - that useEffect() is only called post submit ?

crisp thistle
#

I'm not completely sure. Have you tried running this code?

mint kite
#

True. I think this is more of a react question now. But thanks @crisp thistle . I will try to check some react docs and see how to load that thing on component mount or something.

crisp thistle
#

Sure! So my previous suggestion doesn't work for you?

I think the simplest solution would be to edit your backend to return the clientSecret and the paymentIntent.amount. Then you can display that information on your frontend.

mint kite
#

Fixed it. The problem was that I did not use the right url param

#

my bad

#

Thanks soma.

polar moon
#

glad to hear that, let us know if you need any more help