#nerder

1 messages · Page 1 of 1 (latest)

whole steppeBOT
dense smelt
#

Can you share more details of what you want to achieve? can you share a screenshot from the dashboard ?

versed crest
#

Yes give me a sec

#

The update scheduled badge

#

probably is schedule

dense smelt
#

I think that's a dashboard feature only, there is no public field for that.

dense smelt
versed crest
#

yes, but I think that if the schedule is not null i can safely say that there is an update scheduled?

#

from the webhook i receive this schdule: 'sub_sched_1NByjLLAVB3C1lDIhvQzABIg'

dense smelt
versed crest
#

ok i'll t ry

#

I can create a test clock from an existing sub?

dense smelt
#

no you need to create a new simulation

versed crest
#

Ok understood, the webhook is fired

faint fable
#

Hi! I'm taking over from my colleague. Please, give me a moment to catch up.

#

Please, let me know if you have any other questions.

versed crest
#

no worries

#

i'm still completing the test they tasked me to do

#

ok i've tested it but no luck

#

even if the schedule is complete, is not detached form the subscription 😦

#

Ok i really don't know how to do it actually

faint fable
#

What's the issue you're facing?

versed crest
#

No issue, I'm trying to add a badge similar as the one you have on the dashboard for when there is a scheduled update

#

But I don't know where to find that property

faint fable
#

Sorry, I'm not following. What badge?

versed crest
#

You have access to the thread? Please read above

faint fable
#

Just to double check, you want to know if a Subscription has a Schedule attached?

versed crest
#

I want to present the same information as you do to the user, "update scheduled"

#

My guess was to use the schedule, but after some testing, the schedule is not released when completed

#

what about pending_update ?

faint fable
versed crest
#

yep i see, it should have been schedule, feels like a bug is not removed when completed

faint fable
#

And check if there's a schedule and if the Schedule have phases left.

versed crest
#

i'm doing it like this in my integration

#
    await this.stripe.subscriptionSchedules.update(
      schedule.id,
      {
        end_behavior: 'release',
        proration_behavior: 'none',
        phases: [
          {
            start_date: subscription.currentPeriodStart,
            end_date: subscription.currentPeriodEnd,
            items: [
              {
                price: schedule.phases[0].items[0].price as string,
              },
            ],
          },
          {
            start_date: subscription.currentPeriodEnd,
            items: [
              {
                price: newPriceId,
              },
            ],
          },
        ],
      },
      {
        stripeAccount: gym.accountId.value,
      },
    );
#

but i'm not sure how can i set an end_behaviour from the dashboard

#

release is the default so, is probably not working as you expect it too

#

because even when the schedule is complete, the next subscription.updated has still schedule

faint fable
#

You mean "release" is not set by default, when creating a Schedule from the Dashboard?

versed crest
#

no I mean that when creating a schedule from the dashboard end_behaviour is always release

#

you can't set it to cancel

#

which is fine

#

but still is not "released"

#

you will see what I mean

#

this event has been triggered by the scheduled update, but still you can find schedule set (and not null as expected)

faint fable
#

I think it still has phases to go

#

Let me double check

kind cliff
#

Hi! I'm taking over this thread.

versed crest
#

hey

kind cliff
#

Is your goal to know if an existing subscription schedule has upcoming updates, like a new phase that will start?

versed crest
#

not exactly, my goal is to achieve this

#

and then remove that badge update scheduled badge when the update has been completed

kind cliff
#

You want to remove the badge update scheduled from the Stripe dashboard?

versed crest
#

nope, I want to present it and remove it in my app

#

mimicking how you are doing it in the dashboard

kind cliff
#

Can you share a subscription ID, and clarify exactly what you would like to show in your own app?

versed crest
#

in my app i'm allowing users to downgrade their own subscriptions, but instead of letting them to do that immediately, i schedule the downgrade at the end of their current period

#

this is all working fine, now as a last touch I want to present them a badge in their membership page (in my app) that the update is scheduled to happen and what will happen then (exactly as you are doing here in the dashboard)

#

the problem is that i'm not able to find any parameter to use to achieve such behaviour

#

because even if the end_behaviour is set to release when the scheduled update is completed, and the scheduled update apparently has no more phases is still attached to the subscription object.

#

so I can't reliably use schedule to check if a subscription has still a pending scheduled update

kind cliff
#

You could check the phases of the subscription schedule to see if there are upcoming phases or not.

versed crest
#

because from my tests using test clock schedule doesn't return to null when the phases have completed, so by checking that field i will wrongly present the user a scheduled updated which is non existent

kind cliff
#

But you can check the start_date of the phase to know if there are any upcoming phases or if they all finished

versed crest
#

please check the phases of this sub_sched_1NBzhJLAVB3C1lDIIkdCEnB9

#

they should be all compelted

kind cliff
#

I see two phases, which all have a start_date in the past. So it means there will be no upcoming changes.

#

Oh wait, there is one phase with a start date in June.

#

So there will be one upcoming change in this case.

versed crest
#

nono i think is in the past as well

#

I see what you mean tho, but is very inconvenient to do so, because it means that i need to perform an API call since in the webhook the schedule is not expanded

#

so every time for every user just to present a little badge i need to perform an API call, compare the time and all. I bet you are not doing it like this in the dashboard

kind cliff
#

I have no idea how it's done in the Stripe dashboard, but we probably need to do at least an API call to check.

versed crest
#

another option might be to use some webhook event and save the scheduled update on the customer then fetch it later

#

but I don't see any

kind cliff
#

Well you created the subscription schedule, so you know when the schedule will end. And then you could save that date directly in the metadata of the subscription or the customer object.

#

And there's the subscription_schedule.created event

versed crest
#

yes, the date is not the issue, I know when it will end but there is no difference between a subscription that has a schedule (still active) and one that has one completed

#

I feel like in the end_behaviour is missing something in between release and cancel

#

because with release the sub schedule is still there, but with cancel it will also cancel my subscription right?

#

actually! There is a status in the subscription schedule

half dagger
#

Hi there 👋 jumping in as my teammate needs to step away. Please bear with me a moment while I catch up on the context here.

versed crest
#

Ok, I think we have some options, but are all a bit inconvenient. Maybe you can help me figure out the best option I have here.

half dagger
#

Sorry, there is more context here than I realized, could you summarize what you're trying to accomplish here for me?

versed crest
#

in my app, I'm allowing users to downgrade their own subscriptions, but instead of letting them do that immediately, I schedule the downgrade at the end of their current period.

This is all working fine, now as a last touch I want to present them a badge on their membership page (in my app) that the update is scheduled to happen and what will happen then (exactly as you are doing here in the dashboard). The problem is that I'm not able to find any parameter to use to achieve such behavior because even if the end_behaviour is set to release when the scheduled update is completed, and the scheduled update apparently has no more phases is still attached to the subscription object.

So I can't reliably use schedule to check if a subscription has still a pending scheduled update.

#

pretty much this

#

I want to achieve this in the UI of my app

#

and remove that badge once done with the update

#

My options are:

  1. perform an API call to retrieve the status of the subscription_schedule
  2. listen for subscription_schedule.updated, store it in my DB and keep track of the status
half dagger
#

Do you have an example of a Subscription from your testing where the Subscription Schedule completed with an end_behavior or release but it was still referenced on the associated Subscription. I may be mistaken but I thought the Schedule was unassociated from the Subscription with release.

versed crest
#

yes give me a sec

#

this one

#

the sub_schedule is this one: sub_sched_1NBzhJLAVB3C1lDIIkdCEnB9

#

but it makes actual sense that doesn't ever come back to null, because the sub_schedule keeps track of it with a status so there is no need to clean it up in the sub

#

so I guess it will be in released, but since from the subscription, I can only check for null to understand if there is a sub_schedule or not I need to store it somehow 😦

half dagger
#

It looks like the test clock for that simulation is still in the last phase of the subscription schedule, if you advance the time another billing period does the schedule get removed from the Subscription?

versed crest
#

let me try

half dagger
#

I guess that still probably isn't what you want though, since the Subscription Schedule is already in a state where it won't make any more changes to the Subscription unless it is updated.

versed crest
#

yes exactly

#

in fact in the dashboard the badge is gone

#

but for sure that badge is presented doing along the lines of:

if(sub_schedule.status == 'active') return ScheduledUpdateBadge()
#

this is my only feasible option then

  • listen for subscription_schedule.updated from the webhook, store inside my customer object the sub_schedule and keep track of the status
#

If i understand how is designed, once a sub_schedule is created and attached to a subscription it wont ever being "detached"

half dagger
#

Agreed, I do think it would be a smoother process to track this state on your end.

versed crest
#

yes, even if it will be cool to have the sub_schedule status attached to the sub object

#

i need to do a quite long integration to support this little feature just because I have no way to keep track of that sub_schedule status from the subscription

#

it's ok tho, I will prioritize accordingly. Thank you so much for helping me out here

half dagger
#

Any time! Feel free to reach out if you run into any hurdles with that, we're always happy to help.

versed crest
#

yep

#

there is a way to report this feedback tho?

#

it's a bit of a friction and I know you guys are tracking this kind of things

#

also, there should be some more documentation around this because both you and @dense smelt thought it would be as I expected to (to detach from the sub)

half dagger
#

Yup, I can definitely take down your feedback and relay it to our teams.

half dagger
versed crest
#

ah ok, It actually was at some point!

half dagger
#

Yup, at the end of the schedule's last phase.

versed crest
#

than to me it's even more weird :S

half dagger
#

Definitely agree from the perspective we're looking at it here.

versed crest
#

that's fine

#

thank you so much @half dagger i wont bother you anymore

#

have a good rest of the day and good weekend

half dagger
#

Thank you, I hope you do the same!