#Min.K

1 messages · Page 1 of 1 (latest)

novel ospreyBOT
#

Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

  • Min.K, 1 hour ago, 4 messages
  • Min.K, 5 hours ago, 5 messages
  • Min.K, 2 days ago, 27 messages
  • Min.K, 2 days ago, 13 messages
  • Min.K, 6 days ago, 13 messages
  • Min.K, 6 days ago, 9 messages
    and 1 more
fathom venture
#

hi! you'd need to use a SubscriptionSchedule to do that.

vast bobcat
#

When I call the Create subscription schedule API, I think I need to pass in the subscriptionId for which subscription I want to set it for, but there is no field to pass in the subscriptionId.

vast bobcat
#

Thank you.

I would like to ask two additional questions.

Question 1. After the current subscription cycle ends, I would like to reflect these changes in the next subscription cycle. It looks like I will have to specify the date via start_date, is there any way to do this without such a calculation?

Question 2. After the current subscription cycle ends, I want to replace the product I am subscribed to with a new product in the next subscription cycle. In the Subscription Update API, I've done this via the items.deleted flag, but how do I do this when registering the subscription scheduler?

fathom venture
#

1/ Well you can define the start_date as current_period_end of the subscription instead of calculating it

#
// schedule a change from gold to silver at the end of the period
$sched = \Stripe\SubscriptionSchedule::create([
  'from_subscription' => $subscription->id,
]);

\Stripe\SubscriptionSchedule::update($sched->id, [
  'phases' => [
    [
      "start_date" => $subscription->current_period_start,
      "end_date" => $subscription->current_period_end,
      'items' => [
        [
          'price' => $gold->id,
          'quantity' => 1,
        ],
      ],
      "prorate" => "true"
    ],
    [
      "start_date" => $subscription->current_period_end,
      'items' => [
        [
          'price' => $silver->id,
          'quantity' => 1,
        ],
      ],
    ],
  ],
  "end_behavior" => "release"
]);
#

2/ in the phase.items field you pass the full array describing exactly what Prices should existing in that phase(so AFAIK you don't need to delete the existing items, you just pass phase[i].items as the array with only the new items)