#b33fb0n3_event-plan
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/1280902635360358431
π Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello, so you are both trying to understand how to deep link properly and also if there is a way to change what the customer portal says about the trial?
No, I am looking for a way to have a subscription id (for the deep links) wihtout the customer ever noticed, that he already have a subscription at stripe. It should work in the background
Gotcha, you should be able to turn those emails off in your dashboard settings https://docs.stripe.com/invoicing/send-email#email-notifications
We have individual settings for finalized invoices, successful payments, failed payments, and trial invoices so you may need to turn multiple/all of those off depending on the exact behavior that you are looking for.
I don't even know if there are any emails that I want to turn off. I want to find a way to archive this: #1280902635360358431 message
Can I disable these emails also for only this background subscription?
I mean it's ok, if the email is something like "hey your test started" or whatever, but not "your subscription for 0β¬ started". That would be confusing for the customer
Unfortunately that is an account-wide setting, so it is for all of the subscriptions on the account.
I just reread your description. Is there a reason you are using a 0β¬ instead of our trial functionality? Trials can be set for an arbitrary amount of time and the wording on the email would likely be clearer.
there isn't any reason. How would a subscription creation in nodejs look like with an end and start date? I couldn't find both for trails
If you haven't already, I would recommend checking out our API explorer, it can guide you through building a request and can print out the node code for the request
https://docs.stripe.com/workbench/shell
Based on what you have described, it sounds like you would want to set a trial_end that is when you want the subscription to actually start and a cancel_at for when you want the subscription to end.
I couldn't find both for trails
What does "trails" mean here? That is not immediately ringing a bell for me
What does "trails"
Ah I mean "trial"
So the trial is for a paid subscription or should it be for a product with 0β¬?
Also, what happens when the trial ends and the user haven't done anything in the subscription direction (like giving payment details, selecting a plan, ...)
When the trials is for a paid product: can the user still select other plans? How will he be billed?
That's what I seen here:
Why was the plan inside the webhook event was removed?
case "customer.subscription.created":
const subscription = event.data.object;
const metadata = event.data.object.metadata;
const priceId = subscription.plan.id;
Whoops I really should have caught on to "trials" = "trails". Busy morning.
Yes, we typically recommend using our trial functionality. You can actually customize what your subscriptions do if they get to the end without a payment method. I forget if the customer portal can change plans on trialing subscriptions, I would reccommend trying it out in test mode to confirm what happens there
https://docs.stripe.com/api/subscriptions/create#create_subscription-trial_settings-end_behavior-missing_payment_method
I would reccommend trying it out in test mode to confirm what happens there
Yea, I guess thatβs the best.
What do you think about the webhook issue?
Whoops I really should have caught on to "trials" = "trails". Busy morning.
Happens the best π
Do you have the ID of the event where you are not seeing plan? My initial guess is the API version of your webhook endpoint. That is what mostly determines what fields are available and how objects are rendered.
Sure give me some minutes to find itβ¦
Found. The event id is: evt_1PvLAhK7gRZLSJmg2Xb3uOyq
It looks like plan is in that webhook Event. Do you have another one that doesn't have plan?
oh yea, the event has the plan, but the type from stripe doesn't
I am using this version
"stripe": "^16.9.0",
I thought the issue was that you wanted plan to be in the Event. Can you resummarize the issue for me?
yes, the plan is not inside the object according to typescript
Ah, so Typescript is looking for an old attribute to verify it's present in the Event. I don't think Typescript supports plan right out of the box, so you would need to update it to expect that value, or ignore the lines that validate the lines in the payload that look for plan
ah ok, I thought stripe types are pretty good and pretty good typed....
I checked the customer portal in the meantime and it looks like it's working fine.
Can I somehow update the typescript version? Stripe type normally everything
Or are there others ways to get the price id, when I just have the subscription?
I think that because the Typescript was implemented after we made the switch to Prices (which replaced Plans) it wasn't included. You can see here that, on the Subscription object, which is what you get as the payload for Events like the example you gave, that there is no plan attribute for Typescript to look for: https://github.com/stripe/stripe-node/blob/master/types/Subscriptions.d.ts
You can either add it yourself, or ignore the lines that look for it in your code
oh ok, got it. How can I get the priceId inside the subscription webhooks?
The Price ID is included in the Plan attribute. It's there in the payload, it's just that Typescript isn't aware of it
does typescript know a value where priceId is typed?
Wait, let's back up a second. How are you accessing the Plan in your code? Like, the code from your screenshot that's cut off. What's the line that's getting cut off?
The code itself shows that I trying to access the value subscription.plan.id and setting it to the variable priceId.
In pseudocode its:
If the event type is equal to "customer.subscription.created"
Set subscription to the value of the object property within the event.data object
Set metadata to the value of the metadata property within the subscription object (assuming it exists)
Set priceId to the value of the id property within the plan property of the subscription object
So I just try to setting a variable that comes from the subscription.plan.id.
After the code (switch (priceId) { ... }) I switch the priceId. So if the priceId equal to Y (some price id) then do X (in my case setting up stuff the user is allowed to do).
Okay, but the plan isn't in subscription.plan.id, it's in subscription.items.data[0].plan
b33fb0n3_event-plan
π just to clarify a bit the plan property maps to the Plan object https://docs.stripe.com/api/plans which was deprecated multiple years ago as we replaced it with the Price object https://docs.stripe.com/api/prices/object
They are fully compatible and we recommend that all new code only looks at price and never plan which is why it's been removed from types for multiple years now
that's confusing for me. Why do I see it there?
It's there for backwards compatibility. We haven't deleted the Plan API (and won't) and lots of code relies on it. But it's discouraged. So really ignore plan and Plan entirely and focus on Price
ok, so I focus on the price object. Where is this object in the webhook data? It's missing or am I blind? Is it really this subscription.items.data[0].plan?
Is it really this
subscription.items.data[0].plan
No that is the Plan object
You wantsubscription.items.data[0].price
ahhh there is the price with the price id. Thanks a lot π