#daviscup-checkout metadata

1 messages ยท Page 1 of 1 (latest)

woven comet
#

๐Ÿ‘‹ happy to help

#

yes you could that in multiple ways

#

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

distant pilot
#

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 ^^

woven comet
#

first concerning the webhook event the better event to listen to is checkout.session.completed

#

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}}

distant pilot
#

Ok thank you very much for your help. I'll test this now. Is there any serious danger/problem with using payment.intent.succeeded?

woven comet
#

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

distant pilot
#

Ah I see. Got it. Thank you tarzan! I hope I can make it work! ๐Ÿ˜„

woven comet
#

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

distant pilot
#

Ah that actually makes difference for me

#

๐Ÿ™

#

Thank you !!

woven comet
#

you're welcome