#andrew-subscription-scheduleupdate

1 messages · Page 1 of 1 (latest)

clear citrusBOT
fading lava
#

We don't reopen threads but you can simply ask a new question and we can help

tacit cliff
#

oh okay no problem just saw that message in the message box

#
      customer: data.customer,
      // from_subscription: subscriptionId,
      end_behavior: 'release',
      start_date: data.currentPeriodStart,
      phases:[
        {
          end_date: data.currentPeriodEnd,
          items: [
            {
              price: data.priceId,
              quantity: 0,
            }
          ]
        },
        {
          items: [
            {
              price: updatedPricedIdKey[data.priceId],
              quantity: 1,
            },
          ]
        }
      ]
    }
#

i'm trying to setup a subscription schedule on a current subscription.

  • I want to remove the current product
  • add the new product

Since the invoice is done monthly or annually (depending on the product) I was looking to create a schedule for the upcoming charge

fading lava
#

Sure, so what's the problem?

#

andrew-subscription-scheduleupdate

tacit cliff
#

I wasn't seeing the subscription scheduled, but I see that it created a new subscription

fading lava
#

that's expected, your code explicitly comments out from_subscription and explicitly creates a brand new schedule

#

What you want is
1/ Create a Schedule from the existing subscription
2/ Update that Schedule to add an extra phase to switch to the other product/price

tacit cliff
#

mhmm okay I would have to make 2 separate api calls?

fading lava
#

yes

tacit cliff
#

gotcha i'll give that a go. thank you

tacit cliff
#

can I delete a schedule from the dashboard?

fading lava
#

Not sure, I'd recommend trying/playing with it in Test mode. We focus on code here so we don't use the Dashboard much

tacit cliff
#

created the schedule with the following code

      from_subscription: data.subscriptionId,
    }
#

tried to update the schedule

stripe.subscriptionSchedules.update(data.scheduleId, {
      end_behavior: 'release',
      phases: [
        {
          start_date: data.currentPeriodEnd,
          items: [
            {
              price: data.priceId,
              quantity: 0,
            },
            {
              price: updatedPricedIdKey[data.priceId],
              quantity: 1,
            }
          ],
        },
      ],
    }
#

getting an error when I add start_date
Error: You can not modify the start date of the current phase.

#

without start_date i get
The subscription schedule update is missing at least one phase with a `start_date` to anchor end dates to.

strong junco
#

Likely you're passing a different value for start date

#

Retrieve the subscription schedule and see what the current start date is

#

You can only update the current and future phases on subscription schedules. When updating a subscription schedule, you need to pass in all current and future phases that you want to keep. You still receive information in the response about past phases.