#Peppa

1 messages ยท Page 1 of 1 (latest)

solar spokeBOT
unreal ruin
#

๐Ÿ‘‹ happy to help

wind glen
#

Hi Tarzan ๐Ÿ™‚

#

I already had subscriptions implemented, but now we're trying to offer a "lifetime" package in the form of a one-time purchase.

#

Sadly, I can't seem to distinguish which product the user purchased

unreal ruin
#

you shouldn't be listening to charge.succeeded but instead listen to checkout.session.completed and based on that event you can look at the mode to see whether it's payment = one time payment or subscription which is a subscription

wind glen
#

ahhhh

#

gotcha!

#

thanks!

unreal ruin
#

another thing that you can do

#

is to listen to invoice.paid and payment_intent.succeeded

#

and whenever you get a payment_intent.succeeded event if the invoice property isn't null you ignore the event

#

and in the invoice.paid you can get the subscription property and then retrieve the corresponding subscription

solar spokeBOT
wind glen
#

Yeah sweet, I am using invoice.paid to process subscriptions indeed

#

is there a way to find out which product they purchased from the Checkout.Session.Completed event?

vague hatch
#

๐Ÿ‘‹ stepping in

#

When you receive that Event you want to retrieve the Checkout Session and expand line_items to get the Product info.

#

Are you familiar with expansion?

wind glen
#

eeeehm

#

no not really

vague hatch
#

Okay so take a look at that doc

wind glen
#

let me look throught he docs

#

yeah