#tallmanpapi
1 messages · Page 1 of 1 (latest)
You should rather listen to checkout.session.completed event. For each event, you make a Stripe API call to this endpoint:
https://stripe.com/docs/api/checkout/sessions/line_items
In order to list all Checkout items.
What other details you are looking for ?
It's not necessarily the listener that's wrong, but I would definitely look into this, thank you.
The problem is that my form values are being cleared after I am redirected to the Stripe checkout page.
A solution would be the card component but I want to use the Stripe checkout page.
@carmine current
The problem is that my form values are being cleared after I am redirected to the Stripe checkout page.
When you creat the Checkout Session, are you passing the values that you could collect previously on your website:
https://stripe.com/docs/api/checkout/sessions/create ?
Yes, I do. Everything works and is being sent to the database, but after the Stripe checkout page redirect is made, the values get cleared.
How are you passing these values to Stripe Checkout, I'm not understanding you
What values are you expecting to be displayed/not cleared from the Checkout Session ?
I am not passing anything to the Stripe checkout, I want my form values to be sent to the db after the payment is successful, but my problem is that the form values are cleared when I get redirected to the Stripe checkout page.
@carmine current
If you are not passing value to Stripe Checkout, so that' should be expected
but my problem is that the form values are cleared when I get redirected to the Stripe checkout page.
Can you record a video of this in order to understand your flow/integration?
Yes, of course!
Yes, correct, I am just not very sure how this part with the values passing is working, you know.
Hi! I'm taking over from my colleague. Please, give me a moment to catch up.
Just to clarify, the customers fills out a form on your page before being redirected to Checkout? And you want to save these inputs in your own DB? Am I understanding correctly?
Thank you Vanya!
I appreciate you.
Uhm yes. So currently without Stripe, when a customer fills in form values the values are sent to the db. Now I added a Stripe checkout with a listener, 'switch' and 'case' as shown in the Stripe docs.
But now when I click on the payment button and I am being redirected to the checkout page all the form values are being cleared because I leave the page.
So my question is, do I have to send these values somewhere so I can use the switch 'payment intent succeeded' and send the form values to the db.
Because the switch is working, and the post to the db is also being made, but the values are just not in there anymore.
Let me know if its clear😅
Sure. There's multiple ways to make this work.
When you send a request to create a Checkout Session, you can post the values from your form from your frontend to your backend. Now you have 2 options:
- You can already create a pending record in your database with these values, and then redirect the customer to the Checkout. When you receive
checkout.session.completedevent, you can map it to the database record you created earlier and update it with the new information, e.g. payment completed. - You can use the
metadatafield of the Checkout Session object to persist the values on the Stripe side. When you receive thecheckout.session.completedevent, you will be able to access those fields and create a database record. https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-metadata