#damenz-sub-schedule
1 messages · Page 1 of 1 (latest)
Basically I persist the ID in my DB for further reference. But in the end I need the subscription_id when the scheduled is released
But I only save schedule ID since subscription it not yet created
Hi there! Give me a sec to look for the best way to do this
I am trying to automate commissions
So I need to ultimately save the subscription ID in my DB (which I have a hard to to find how to get that subscription ID via the schedule)
So that when there is a payment intent webhook, I fetch the associated invoice and check if this is associated to a subscription, try to find a match in my DB and then give commisison to my sale rep
You stated you attempted to listen for webhooks... are you using the subscription.schedule.released hook?
That should contain the Sub Schedule, which should also have the Sub ID at the time that event fires.
Thanks for providing the event, let me take a glance at it
evt_1KlbyILiVV9UQF8ghOtRUJa4
is the event of "customer.subscription.created" that followed the release
Huh, indeed subscription is null... I thought we did persist the Sub ID here. But perhaps not
Let me do some digging
RELEASE
evt_1KlbyELiVV9UQF8gi27gwJOD
Subscription created
evt_1KlbyILiVV9UQF8ghOtRUJa4
Payment intent succeeded
evt_3KlbyFLiVV9UQF8g3hYDbIbf
in order
Ah, that sub schedule was never attached to a Subscription? Unless I'm missing it?
The workflow I am trying to achieve
1- Create a schedule
2- Schedule transforms into a subscription (I need to get the subscription ID here)
3- Listen to any payment intent succeeded
4- Fetch invoice associated to payment intent
5- If invoice is associated to a subscription, check in my DB if I have the subscription ID
6- Give commission
Have you tested with actually attaching the Sub_schedule to a Subscription?
Like completing step 2 there above?
I think you want to listen for subscription_schedule.updated
Which should fire when the Sub_schedule attaches to a Subscription
I haven't tested this in a while so I don't remember 100% but I'm pretty sure that is the case and I would recommend that you do the full test.
Sorry had a phone call
Actually this one is a scheduled I created earlier before opening the ticket
I manually changed the start_date to today (see event)
evt_1KlbyELiVV9UQF8gSVG8RYhA
that triggered the others (release, subscription created... etc)
Sadly it seems I cannot use test clocks for scheduled
whish I could try it this way
Its just says "Add subscription" so its gonna create it right away without a schedule no ?
I really have a hard time understand the logic of scheduled
Lets do it together
You set a test clock on a customer
Really though, why do you need to even use test clocks? You mostly just want to create a schedule and then associate a subscription to see the events that fire, right?
yeah
ok so Im gonna create a test clock for a subscription on may 7
it only fired customer.subscription.created
Okay let's back up. You had already created sub schedules and released them before we started chatting.
Yeah but I just did a new one using the test clock
unless you meant to do it via api ?
Your model here is to use Sub Schedules to start Subscriptions in the future, correct?
And you are going to do this by using start_date
On your Sub schedule
correct
Okay, so let's do this the simple way. Just create the sub schedule and set the start_date for 1 minute from now.
Instantly generate a free, unique URL and email address to test, inspect, and automate (with a visual workflow editor and scripts) incoming HTTP requests and emails
here
i will redirect webhook there
so you can see in real time
so you want me to do it via api?
Sure, API will likely be easiest imo
I also can see your Dashboard so no worries on being able to see the webhooks
Great!
Now let's wait 1 minute 🙂
"subscription": null, so far
on the first event
hmm still nothing
does it take long to trigger?
ah here it is
Yep sorry sometimes it does take a few minutes in testmode
So evt_1Klcf0LiVV9UQF8gdmLeSN5b is the event you want
And you can see the Subscription ID is set there
its not being released, just updated?
Correct it hasn't been released yet
Released is for when the schedule ends
Which is dependent on the phases
thats a monthly subscription that never ends
so when should it be released in this case?
What have you tested? We have a handy feature called Test Clocks that helps you test out subscriptions and subscription schedules to see what changes will occurr over time.
https://stripe.com/docs/billing/testing/test-clocks