#damenz-sub-schedule

1 messages · Page 1 of 1 (latest)

sturdy finch
shut saddle
#

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

sturdy finch
#

Hi there! Give me a sec to look for the best way to do this

shut saddle
#

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

sturdy finch
#

You stated you attempted to listen for webhooks... are you using the subscription.schedule.released hook?

shut saddle
#

yeah

#

evt_1KlbyELiVV9UQF8gi27gwJOD

sturdy finch
#

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

shut saddle
#

evt_1KlbyILiVV9UQF8ghOtRUJa4

#

is the event of "customer.subscription.created" that followed the release

sturdy finch
#

Huh, indeed subscription is null... I thought we did persist the Sub ID here. But perhaps not

#

Let me do some digging

shut saddle
#

RELEASE
evt_1KlbyELiVV9UQF8gi27gwJOD

Subscription created
evt_1KlbyILiVV9UQF8ghOtRUJa4

Payment intent succeeded
evt_3KlbyFLiVV9UQF8g3hYDbIbf

#

in order

sturdy finch
#

Ah, that sub schedule was never attached to a Subscription? Unless I'm missing it?

shut saddle
#

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

sturdy finch
#

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.

shut saddle
#

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

sturdy finch
#

I thought you can use test clocks with sub schedules?

#

Why can't you?

shut saddle
#

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

sturdy finch
#

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?

shut saddle
#

yeah

#

ok so Im gonna create a test clock for a subscription on may 7

#

it only fired customer.subscription.created

sturdy finch
#

Okay let's back up. You had already created sub schedules and released them before we started chatting.

shut saddle
#

Yeah but I just did a new one using the test clock

#

unless you meant to do it via api ?

sturdy finch
#

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

shut saddle
#

correct

sturdy finch
#

Okay, so let's do this the simple way. Just create the sub schedule and set the start_date for 1 minute from now.

shut saddle
#

here

#

i will redirect webhook there

#

so you can see in real time

#

so you want me to do it via api?

sturdy finch
#

Sure, API will likely be easiest imo

shut saddle
#

ok

#

done

sturdy finch
#

I also can see your Dashboard so no worries on being able to see the webhooks

#

Great!

#

Now let's wait 1 minute 🙂

shut saddle
#

"subscription": null, so far

#

on the first event

#

hmm still nothing

#

does it take long to trigger?

#

ah here it is

sturdy finch
#

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

shut saddle
#

its not being released, just updated?

sturdy finch
#

Correct it hasn't been released yet

#

Released is for when the schedule ends

#

Which is dependent on the phases

shut saddle
#

thats a monthly subscription that never ends

#

so when should it be released in this case?

supple mirage