#stereozwo_api
1 messages · Page 1 of 1 (latest)
👋 Welcome to your new thread!
⏱️ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime!
🔗 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/1212729389083791361
📝 Have more to share? You can add more detail below, including code, screenshots, videos, etc.
⏲️ 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. Thank you for your patience!
It is also important that there is no pro rata calculation. The customer should be charged the new price on the next invoice.
Yeah you need to specify the si_xxx ID you want to update/change otherwise it'll add a new item: https://docs.stripe.com/billing/subscriptions/upgrade-downgrade#changing
No problem, glad I could help!
This will be trickier I suspect. You may need to utilise a trial period to keep the period dates the same: https://docs.stripe.com/billing/subscriptions/billing-cycle#add-a-trial-to-change-the-billing-cycle
Because otheriwse the update will trigger a new invoice/period for the full amount upfront
And 'reset' the cycle time to that moment
I can use the dashboard to set that no pro rata calculation takes place. Does this work via the API with 'proration_behavior' => 'none'?
Yes, but it'll bill them immediately for the full amount I suspect
I'll try it. The tips are very valuable!
Can you have a look at this req_rOmNY9eW83zxSV
Sure, items should be an array. Looks like you just passed an object. Can you share the code?
try {
$subscription = \Stripe\Subscription::retrieve($user['stripe']['subscription']);
$updated_items = [
'id' => $subscription['items']['data'][0]['id'],
'price' => $price,
];
$subscription = \Stripe\Subscription::update(
$user['stripe']['subscription'],
[
'items' => $updated_items,
'proration_behavior' => 'none', // Keine anteilmäßige Berechnung
]
);
return $subscription;
} catch (\Stripe\Exception\ApiErrorException $e) {
$body = $e->getJsonBody();
$err = $body['error'];
return "error:" . $err['message'];
}
Hi @frozen trellis I can't seem to reply in my thread. Could you authorize me to please?
It's probably closed. Ask a new Q in #help
@thorn relic Should be:
$updated_items = [[
'id' => $subscription['items']['data'][0]['id'],
'price' => $price,
]];