#daviscup-checkout metadata
1 messages ยท Page 1 of 1 (latest)
๐ happy to help
yes you could that in multiple ways
if you already have all of the user information in your db and you just want to link to the userId you have you could use the client_reference_id https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-client_reference_id
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
otherwise since you are receiving the payment_intent.succeeded event (which I don't really recommend but we could go back to that later) you could use the metadata on the Payment Intent object that will be created for that Checkout Session
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Oh I see. I don;t have the user info in my DB already.
When creating the stripe session, I'd attach my user data like this?
const stripeCheckout = async () => {
try {
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
mode: 'payment',
metadata: { userData },
and payment_intent.succeeded is not a good way to check if the payment succeeded? I copied it from the docs so I though this is the way to do it ^^
first concerning the webhook event the better event to listen to is checkout.session.completed
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
if you still want to use the payment_intent.succeeded event, the metadata object you used in the snippet you just shared would not be available, since it is attached directly on the checkout session object. instead you should use the payment_intent_data: { metadata: {userData}}
Ok thank you very much for your help. I'll test this now. Is there any serious danger/problem with using payment.intent.succeeded?
no but the idea is that other products of Stripe emit also the payment_intent.succeeded event (e.g. invoices) and you might want to use those products later on and that would be a conflict in the way you handle the event
so it's a better way of listening to right event
Ah I see. Got it. Thank you tarzan! I hope I can make it work! ๐
it's also the event we recommend using in our docs https://stripe.com/docs/payments/checkout/fulfill-orders#fulfill
and and the checkout object holds more information about the checkout session, the payment intent object you receive from the event you're listening to doesn't give you access to the items etc...
you're welcome