#mick23_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1270125312943853568
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi there, can you share your question?
Think I'm missing a piece of the puzzle. How do I get this bit of info in the SaaS + Stripe Pricing Tables (+successful checkout) workflow? So that ultimately I can turn on the feature that the user has just subscribed to.
What bit of info?
So on successful checkout, it redirects to mysaasapp.com/thank-you?checkoutSessionId=123
But because the checkout has completed successfully, when I try to query the session, it's null because it has been completed
So to map this out. Subscription = Invoice (conceptually, I know they are two sides of the same coin in Stripe terminology), and Subscription Item = Invoice Line Item (aka. What Product the customer has Subscribed to, and hence so I can turn this feature on in the SaaS application.
when I try to query the session
What does this mean exactly? Can you outline what you're trying to do and where you're blocked?
So to simplify this. What I have is;
- Customer in SaaS: Purchase Subscription via Stripe Pricing Table
- On Successful Checkout (Checkout may be the incorrect terminology here Stripe wise, so what I mean by this is successfully making a Subscription via the Stripe Pricing Tables embedded into SaaS app)
- Redirect to myapp.com/thank-you
4.1. I've managed to successfully get the following code;
Session.retrieve(stripeCustomerCheckoutSessionId).getSubscription;
Which I can then use to get the Stripe Subscription ID, i.e. sub_abc123, and save to SaaS DB
4.1. (This is the bit I'm struggling with) How do I get the Subscription Items next from the Session so I can understand what the user has successfully purchased?
There seems to be a bit for session.getLineItems but that seems to be null afterwards, assuming this is because the session has now technically been completed at this point so there are technically no line items associated with it any more.
Is that making sense?
Kind of
i.e. this is the error I'm getting;
java.lang.NullPointerException: Cannot invoke "com.stripe.model.LineItemCollection.toString()" because the return value of "com.stripe.model.checkout.Session.getLineItems()" is null
Ah
When retrieving the Checkout Session, you'll need to expand line_items. Unless explicitly expanded, we don't return the value: https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-line_items
Great!
Then I assume next step after this would basically be;
if (customerHasSubscription) then (display link to Stripe Customer Portal, where they can edit their subscriptions, and manage different products over time and number of licences etc. Then use Webhooks to power everything else from this point)
^^^ in SaaS App
I'll have a play with that bit next anyhow
display link to Stripe Customer Portal
Probably more like display a button that, when clicked, creates a portal session
Sorry yeah, that's what I meant by that.