#mobileengagement | subscription update
1 messages · Page 1 of 1 (latest)
Its important that metered billing is still calculated at the end of the month based on the previous subscription.
[09:44]
Billing runs from the 1st to the last day of the month
Hi there, only usage-based pricing will be billed at the next of billing cycle, so the workaround is to use usage-based pricing for all your prices and you need to report the usage before the end of the billing cycle.
What I am trying to do is UPDATE the current subscription and for that update to take place on the 1st of next month. Is this possible. OR do I have to cancel the existing subscription and start a new one (on free trial) till months end. Confused
I have read how to change a subscription immediately but not with a delay
To clarify Flat Rate and Volume where paid at the beginning of the current month. Glad to hear that metered billing wont change. Makes sense. But I still can't work out the best way to upgrade the fixed costs of the plan to start at the beginning of the next billing period. Any ideas
Hey! Taking over for my colleague. Let me catch up.
UPDATE the current subscription and for that update to take place on the 1st of next month
You can update the subscription, with no proration and set the billing_cycle unchanged (if its already the first of the month)
https://stripe.com/docs/api/subscriptions/update#update_subscription-proration_behavior
Otherwise, you can use Subscription Schedule in order to design this:
https://stripe.com/docs/billing/subscriptions/subscription-schedules
checking
So let me confirm my understanding.
$stripe->subscriptions->update(
'sub_1MdVI12eZvKYlo2CkV5lqolI',
['metadata' => ['order_id' => '6735']]
);
This would add the order id to the existing meta data or replace the meta data as an example
Likewise, if I give a list of items, does this replace the current items
Then I used proration_behavior = none
And thats it?
here you are just updating the subscription metadata, there is no impact on the subscription billing.
yes, I invite you test it
You can create simulation using test clock and analyze this:
https://stripe.com/docs/billing/testing/test-clocks
I am using the following code but getting several errors
$result = $stripe->subscriptions->update(
[
$subscriptionid,
'items' =>
[
[
'price' => $plan,
'quantity' => 1,
],
[
'price' => $excess,
],
[
'price' => $certificates,
'quantity' => $certificatecount,
],
],
'proration_behavior' => 'none',
'metadata' => ["subscription" => $description,"clientid" => $clientid,"certificates" => $certificatecount],
]
);
Warning: trim() expects parameter 1 to be string, array given in /var/www/html/webcontent/webfiles/html/admin.save.social/public/manage/stripe/vendor/stripe/stripe-php/lib/Service/AbstractService.php on line 96
Warning: urlencode() expects parameter 1 to be string, array given in /var/www/html/webcontent/webfiles/html/admin.save.social/public/manage/stripe/vendor/stripe/stripe-php/lib/Service/AbstractService.php on line 103
Fatal error: Uncaught (Status 404) Unrecognized request URL (POST: /v1/subscriptions/). If you are trying to list objects, remove the trailing slash. If you are trying to retrieve an object, make sure you passed a valid (non-empty) identifier in your code. Please see https://stripe.com/docs or we can help at https://support.stripe.com/. thrown in /var/www/html/webcontent/webfiles/html/admin.save.social/public/manage/stripe/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38
The structure is identical to the format used on the original subscription
$subscriptionid is a string
Warning: trim() expects parameter 1 to be string, array given in /var/www/html/webcontent/webfiles/html/admin.save.social/public/manage/stripe/vendor/stripe/stripe-php/lib/Service/AbstractService.php on line 96
Warning: urlencode() expects parameter 1 to be string, array given in /var/www/html/webcontent/webfiles/html/admin.save.social/public/manage/stripe/vendor/stripe/stripe-php/lib/Service/AbstractService.php on line 103
Those are warnings..
You are not passing the subscription Id in your request.
Check the example at
https://stripe.com/docs/api/subscriptions/update?lang=php
$stripe->subscriptions->update(
'sub_123',
[....]
);
$result = $stripe->subscriptions->update(
[
$subscriptionid,
'items' =>
[
$subscriptionid is the subscriptionid and is a string
You should do this:
$result = $stripe->subscriptions->update(
$subscriptionid,
[
'items' =>
[
check the sample please
Ah, subtle but true. Thanks for that. OK getting a new error
Fatal error: Uncaught (Status 400) (Request req_3oVncwkNIo1QA2) Cannot add multiple subscription items with the same plan: price_1Mb6plIvSjr3oTuQy37topnZ thrown in /var/www/html/webcontent/webfiles/html/admin.save.social/public/manage/stripe/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38
There are 3 parts to the subscription.
price_XXX
price_aaa
price_bbb
The format is the same as when the sub was created
I think what may be happening is we are ADDING ITEMS to the existing plan. Where we should be REPLACING ITEMS in the existing plan. What do you think? And what can we do? Thanks
Give couple of minutes while I check this please
mobileengagement | subscription update
It seems the statement "I think what may be happening is we are ADDING ITEMS to the existing plan. Where we should be REPLACING ITEMS in the existing plan." is true. I am not recording the subscription item ids in my database so currently looking to see if I can. I think we then do 3 subscriptionItems updates
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Specificaly "Update a subscription item"
Is there a better way
Hi! I'm taking over this thread.
Is your goal to change the price of an existing subscription (instead of adding a new price to the subscription)?
If so, we cover this here: https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#changing
Notice that we place a price and an ID, to replace the existing price. If you forget to pass the ID, it will add a new price.
we are 3 parts of the subscription
Plan : 1K PM, 3K PM, 6K PM and 12K PM / 10K PA, 30K PA, 60K PA, 120K PA
Certificates: £100 pm pr £1000 pa - First free, then subsequent are charged monthly / annually
Metered : Monthly Target or Annual Target
So its quite complicated
I want update the subscription to reflect these changes from the beginning of next month
So each option has its own price_id
Do I simply swap the current price and quantity with the new price and quantity for each subscription item
So the subscription has 3 price IDs, and you want to update all three at the same time?
Yes that's possible, you need to do something like this:
items: [{
id: "si_xxx", // existing subscription item ID
price: 'price_xxx', // new price ID
},{
id: "si_xxx", // existing subscription item ID
price: 'price_xxx', // new price ID
},{
id: "si_xxx", // existing subscription item ID
price: 'price_xxx', // new price ID
}]
as covered here: https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#changing
however this will change the price of the subscription immediately, and not at the next billing period.
Since we charge in advance and will use proration_behavior = none
Although the plan will change immediately there would be no impact until the next billing cycle?
Probably the only difference is that there metered rate would be based on say ANNUAL TARGET before they have paid for an annual subscription due on the 1st. I can live with that?
Is my assumption correct?
I am testing
$result = $stripe->subscriptions->update(
$subscriptionid,
[
'items' =>
[
[
'id' => $planid,
'price' => $plan,
'quantity' => 1,
],
[
'id' => $excessid,
'price' => $excess,
],
[
'id' => $certificateid,
'price' => $certificates,
'quantity' => $certificatecount,
],
],
'proration_behavior' => 'none',
'metadata' => ["subscription" => $description,"clientid" => $clientid,"certificates" => $certificatecount],
]
Since we charge in advance and will use proration_behavior = none
Although the plan will change immediately there would be no impact until the next billing cycle?
Yes I think so. But I recommend to test everything is test mode to make sure it works as expected.
thanks
Problems
$result = $stripe->subscriptions->update(
$subscriptionid,
[
'items' =>
[
[
'id' => $planid,
'price' => $plan,
'quantity' => 1,
],
[
'id' => $excessid,
'price' => $excess,
],
[
'id' => $certificatesid,
'price' => $certificates,
'quantity' => $certificatecount,
],
],
'billing_cycle_anchor' => 'unchanged',
'proration_behavior' => 'none',
'metadata' => ["subscription" => $description,"clientid" => $clientid,"certificates" => $certificatecount],
]
);
I get the error Fatal error: Uncaught (Status 400) (Request req_WXD5y6dyiCaECy) Changing plan intervals. There's no way to leave billing cycle unchanged. thrown in /var/www/html/webcontent/webfiles/html/admin.save.social/public/manage/stripe/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38
If I remove the billing_cycle_anchor from the code it charges the customer immediately
Please advise. Thanks
Well you are changing the plan interval, then we need to change the billing cycle anchor, and yes it will charge the customer immediately.
In this case you would need to use Subscription Schedule to schedule the change of plan at the end of the current billing period https://stripe.com/docs/billing/subscriptions/subscription-schedules
I do not want to change the billing interval.I want it to stay the same. 1st of the month. All I want to change is the items
But the new price are changing the plan interval.
And when you change the plan interval, Stripe automatically change the billing cycle.
OK let me run a quick test
This is mentioned in the link I shared earlier:
If both prices have the same billing periods—combination of interval and interval_count, the subscription retains the same billing dates. If the prices have different billing periods, the new price is billed at the new interval, starting on the day of the change.
https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#changing
So if you need to change the plan interval and also not charge the customer immediately, then the only option is to use Subscription Schedule.
So are you saying the system is incapable of changing items and starting at the beginning of the declared billing cycle. Because i tried 'billing_cycle_anchor' => $billingtimestamp,
'proration_behavior' => 'none', and it didn't like it. I got this error
Fatal error: Uncaught (Status 400) (Request req_OYSE6TqOQyoG2M) When updating an existing subscription, billing_cycle_anchor must be either unset, 'now', or 'unchanged' thrown in /var/www/html/webcontent/webfiles/html/admin.save.social/public/manage/stripe/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38
You can't achieve your scenario using Subscription API, try using Subscription Schedules:
https://stripe.com/docs/billing/subscriptions/subscription-schedules
Wow talk about complicated. OK Plan B. Wouldn't it be easier to cancel the existing subscription and create a new one with a future start date and proration_behavior: none
yes that's an option too
how do i set a subscription to cancel at the end of the current billing period
found it - thanks
OK slightly different FYI. You update the current subscription with cancel_at_period_end
= true and add a new subscription to start at the beginning of the next billing period