#PARAS DOCS-payment-confirmation
1 messages · Page 1 of 1 (latest)
Hi 👋 listening to webhook events is usually the best way to do this, but the question is a bit vague so I'm not sure if it'd be a good fit for your scenario.
https://stripe.com/docs/webhooks
Oh, Checkout Sessions?
const domainURL = process.env.DOMAIN;
const { priceId } = req.body;
const session = await stripe.checkout.sessions.create({
payment_method_types: ["card"],
mode: "payment",
line_items: [
{
price_data: {
currency: 'usd',
product_data: {
name: 'T-shirt',
},
unit_amount: 2000,
},
quantity: 1,
},
], // ?session_id={CHECKOUT_SESSION_ID} means the redirect will have the session ID set as a query param
success_url: `https://localhost:3000/success?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `https://localhost:3000/`,
// automatic_tax: { enabled: true }
})
return res.redirect(303, session.url)
});
yes i created checkout session
after sucessfull payment user redirect to sucess url but how i know he paid sucessfully
i want save data on database after payment
The code that you showed is passing the checkout session's ID to your success page, so you can consume that to retrieve the checkout session 0, find the payment intent for that session 1, and check its status.
Or you can listen to webhook events to track the state of the session and store that on your end for reference.
retrive work at client side or server side?
'cs_test_a1f2Nrb89tSXeGRDSyFalaOt9q2WBlFoN0lV2sJZocBVMYopIyzoEIrznP'
);``` which key is this?
The ID will be provided to your client-side success page, but you'll need to do the retrieval server side.
ohk
That isn't a key, it's an ID for a checkout session.