#Shybes
1 messages · Page 1 of 1 (latest)
Gotcha, and again apologies we missed your followup.
Can you tell me a bit about what you were looking at for those sessions in the last thread?
Hi, stepping in here and catching up
I'm still unsure what the issue is here. Can you summarize the outstanding question here please? What are you expecting to see vs. what you're seeing?
Sure! Basically when applying the discount code for the free trial, we're noticing the the UI does not reflect that discount anywhere. But, if we apply the same discount code into the regular subscription, it shows up fine.
So you're expecting to see 'Then $49.00 per year' on thet 7 day free trial screenshot?
Either that, or, to see $99.00 crossed out and replaced with 49$ per year.
Just some method of knowing that the discount is accurately applying for the free trial, for both ourselves, and our potential users.
👋 quick question - how are you applying the discount code? In both the examples you gave I'm not seeing a discount applied to either of them
@keen cedar we created a coupon & include that coupon id in the discount field when we do checkout.session.create()
The Checkout Session IDs you gave don't include any coupon or discount though - did you maybe send over the wrong ones?
I don't think so? This is the image where it's accurately applying.
Which CHeckout Session is that for? When I look at the CHeckout session for cs_test_a1NZBOt99NujWdJGG02a7tvXjQaOrFO9OxVd4iFwMskiHBkPpMySVkRal1 I see this:
Also, to follow up on the subscription scheduler, what event can we capture with the webhook to check if the user actually renewed their subscription instead of cancelling?
oh. odd, I'll see if i can grab another one, but it might take a little bit. We pivoted onto some other work.
seems like i sent over the wrong test checkout session
Are you asking which event you need to listen to to know that a subscription renewal was paid for?
I'm not fully following what you mean by "instead of cancelling"
Correct, and, in the circumstance where their renewal was not paid for - how we can catch that interaction so we can demote their user tier on our backend.
You can listen for the invoice.paid webhook event to know that a Subscription invoice has been paid for
And the invoice.payment_failed for when a user hasn't paid and need to demote them
I can't remember if I recommended this to you already or not, but you should definitelt read through https://stripe.com/docs/billing/subscriptions/webhooks if you get the chance
im still struggling a little with knowing if they canceled before free trial ended (because trial ending isn't listed as something that triggers subscription.updated), or knowing what they bought when the complete checkout.
Is it important for you to be able to distinguish whether the subscription was cancelled before or after the trial? And a trial ending would definitely trigger a customer.subscription.updated event
ah, if it triggers the customer.subscription.updated event that definitely makes things easier
but yeah it should be important to distinguish if their subscription was cancelled before or after, since once requires immediate demotion of their subscription tier, whereas the other requires waiting till the end of their subscription period
Yeah a customer.subscription.updated will be triggered for ANY change that is reflected on the subscription - a subscription changing statuses (like trial -> canceled or trial -> active) would all have those updated events
Also, just to confirm :
- subscription.updated to see if trial ended
- subscription.canceled to see if user canceled
- subscription.past_due / invoice.failed to see if they didn't pay to renew subscription but didn't cancel?
yup!
And just to be clear - a lot of these events can be used for different things (in particular, the customer.subscription.updated event can be used for a lot of different applications because it's triggered for all changes)
So I'd start with the events we suggested, test them out and see how they're working for you, and if there are any that don't quite work you can see which other events are a good alternative
awesome
while i still have ya
I still don't know how to get the product from the checkout session completion which I think I have to do because I need see if they did pay for the 2 years upfront, but shouldn't I be able to use subscription.created for that? (since i create subscription for 2yr w/ free trial when they buy the 2 years upfront)
Yeah, so you can either use the customer.subscription.created event OR you use the checkout.session.completed event and retrieve the line items (https://stripe.com/docs/api/checkout/sessions/line_items) for that Checkout Session to see what items they paid for
perfect
thank you so much!
this was a little bit of a headache at first but definitely feelin much better about some of this stuff lol
glad we could help a bit!
and if you get a chance to share those different checkout session ID feel free - I tried reproducing your issue on my end and am seeing coupon being reflected correctly with a trial, so seeing your specific checkout sessions would help
Let me see if i can pivot over
btw, when i did ./stripe trigger checkout.session.completed it seemed like there were no line items in event.data
ex :
elif event.type == "checkout.session.completed":
       print(event.data)
Yeah that's why you have to retrieve those line items separate using the API I shared (https://stripe.com/docs/api/checkout/sessions/line_items) - line_items on Checkout Sessions are expandable so they're not included on the object by default
Gotcha
yeah that definitely makes sense
Okay, here ya go
cs_test_a1fjUZnk9g9u66pIV9a9zCNgda6wXWrbQAqI1ibZG4xJsG6Ko5xFPgHVxz
doesn't seem like there's any mention of the coupon anywhere
Your checkout session request isn't passing in anything for discount when it's creating the Checkout Session - if you look at the CHeckout Session creation request here (https://dashboard.stripe.com/test/logs/req_r9R6VQvDHAk4Mb) you can see you don't pass in the discount/coupon anywhere
gotcha
Okay, thank you!
That should be everything from me, really appreciate your help once again.
also, seems like you definitely caught one of my derps, was setting the coupon in our /create-session-checkout endpoint, but not at our /register endpoint lol
annnyways, feel free to close out this thread whenever 🙂