#deinonychus_subscription-schedules

1 messages ¡ Page 1 of 1 (latest)

proper gyroBOT
#

👋 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/1402674542253703271

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

woeful verge
#

my favourite dinosaur since i was a kid

upper onyx
#

hell yeah!

woeful verge
#

the real velociraptor, not the little chicken they inflated for the movies

upper onyx
#

yes, that's how we trigger the upgrade process

woeful verge
#

In this case, that update will always be applied, and then the invoice/payment attempt happens subsequently

upper onyx
#

what's the usual way people manage subscription upgrades? are we using an unconventional flow?

woeful verge
#

No your flow is fine, but you can't do updates conditional on payment success this way

lucid hill
#

Our current flow is something like:
User is subscribed to Product A ->
User changes their product in our app ->
We do our checks to know if that's considered an upgrade or a downgrade ->
We create a sub schedule having their current product as phase 0 and new product as phase 1 ->
Whenever it's considered an upgrade, first phase ends immediately, if it's considered a downgrade, first phase ends at the cycle end

Is that the good way? (sorry for hijacking lol)

woeful verge
#

This lets you do what you ask, indicate the change you want to make, produce an invoice to be paid, and only apply/commit the change once payment on that succeeds

#

And if you hit a phase change during the pending invoice window, it'll be reverted/voided and you'll need to apply a new change

upper onyx
#

ok so the key is PaymentBehavior = "pending_if_incomplete",

lucid hill
#

And that PaymentBehavior is part of the subscription object or can it also be find somewhere inside the sub schedule? (at its creation/update)

proper gyroBOT
woeful verge
#

That functionality is not supported through schedule updates, no

#

Only updates directly to the subscription

#

(payment_behavior parameter is not exposed via schedule updates)

lucid hill
#

Ok, so how could we make it work on our flow?
We would need to call a sub update with payment_behavior before creating the schedules, right?
Cause as of now, all our sub changes are handled by schedules

woeful verge
#

You would need to make this pending update via the subscription, yes

upper onyx
#

So we tried calling the subscription update with payment behavior before the schedule update, and it doesn't seem to trigger any actual update in stripe

var subscriptionUpdateOptions = new SubscriptionUpdateOptions
                                {
                                    PaymentBehavior = "pending_if_incomplete"
                                };
await subscriptionService.UpdateAsync(updateParameters.Subscription.StripeId, subscriptionUpdateOptions);
#

Are we missing an option?

proper gyroBOT
fresh ferry
#

Hi, taking over as my teammate needs to step away. Let me catch up.

upper onyx
#

there it is req_rdOMyYgXrJETYK

fresh ferry
#

Taking a look

lucid hill
#

So instead of having that param as an update, we could have it directly at the sub creation?

upper onyx
#

I'm going to try this

fresh ferry
#

Yes!

#

Actually, that is not true

#

pending_if_incomplete is only used with updates and cannot be passed when creating a Subscription.

#

Let me test this end to end and confirm, hang tight. It has been a while when I tried this flow.

upper onyx
#

No worries, thanks a lot

#

'Setting payment_behavior to pending_if_incomplete has no effect when creating a subscription.'

proper gyroBOT
fresh ferry
#

Can you also update the price on that subscription update call please https://docs.stripe.com/billing/subscriptions/pending-updates#update-subscription ? The latest call to just update the payment behavior does not make sense. The way this works is when you make an update to an existing subscription, if the payment succeeds, you'd want to proceed. When the payment fails, you'd get pending_update hash with the changes.

#

Yeah, sorry fo the confusion. When you pass another price to either downgrape or updgrade, it works as expected.

upper onyx
#

we're making the price change via a schedule update

#

Looking at the docs, we're wondering if default_incomplete would work when creating the initial subscription

fresh ferry
#

This request is not using subscription Schedules: https://dashboard.stripe.com/test/logs/req_PFxxaHp4VJMfgg and instead is using subscription. Can you use the subscription schedules and use the subscription update to the payment behavior? Once I have your full flow, I will be able to test this end to end. Can you create the subscription schedules and the make an update to the subscription to update the payment behavior? You can use Test Clocks: https://docs.stripe.com/billing/testing/test-clocks

lucid hill
#

This was the request that was made after the other req previously shared

fresh ferry
#

Let me try to reproduce this fully

fresh ferry
#

Ok, that did not work. The subscription schedule is just updated. I have filed a feedback with the product owning team to allow passing pending_if_incomplete changes to subscription schedules.

#

If that works, default_incomplete works for your business use case works, sure.

#

However, default_incomplete is to create Subscriptions with status=incomplete when the first invoice requires payment, otherwise start as active. From the way you described your use case, you're looking to decide the behavior when it comed to the subscription schedules update correct?

#

If that is the case, I think you will manually look at the failed event and then update the subscription again to the original price.

upper onyx
#

We were hoping to not have to revert to a previous status/product.

For now we're trying to update a subscription item with the new price and passing the pending_if_incomplete at the same time, then updating the schedule like before. Though we're not quite sure how that'll work with downgrades that make deferred payments at the end of the billing cycle.

fresh ferry