#cansozbir-discount-checkout

1 messages ยท Page 1 of 1 (latest)

native shale
#

ah you are using Checkout, I missed that part, reading

high glade
#

sorry, probably I couldn't explain it clearly, just a junior dev here ๐Ÿ™‚

native shale
#

no you're fine!

#

from the CheckoutSession

#

to get the expanded Discounts which will have the relevant Coupon code used on that payment

high glade
#

yeah but on session, user can close the page and decide to not pay too right ?

honest laurel
#

But what would be the problem with that?

high glade
#

the problem is that, I want to know, which customer bought what, and which discount code he has used if there are any

#

I think this is something we can see on stripe dashboard

#

but we need this data on database, to use it with our power bi integration

honest laurel
#

But my colleague explained exactly how to get this. Then you said "but what if they close the page and don't pay" in which case it doesn't matter since they didn't pay

high glade
#

no no, for example, we have a few telemarketers, each has their own discount codes to promote to people,
On our database, we need to have, who bought what by which discount code.

When we create the checkoutsession, if I create an entry which says Alice used Bob's discount code. Then this is wrong, because she didn't payed yet.

#

by using the code, I mean, buying the product with, not just typing it to the page.

honest laurel
#

1/ Create a Checkout Session
2/ Redirect to Checkout
3/ Wait.
4/ Customer pays
5/ Look at the Session after they pay, check if they used a discount code
6/ done

high glade
#

yeah I was just thinking about a similar solution right now ๐Ÿ™‚
Thank you!

#

So I'll just create a database entry on checkout session, and then, when paymentIntent comes, I'll check the database and set a field called "is completed" as true.

honest laurel
#

You should listen to checkout.session.completed

#

that's the Event that tells you the customer completed Checkout. Then at that point you use the API to look at the discount details

#

Does that make sense?