#stereozwo_api

1 messages · Page 1 of 1 (latest)

formal lagoonBOT
#

👋 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!

thorn relic
#

It is also important that there is no pro rata calculation. The customer should be charged the new price on the next invoice.

gray falconBOT
frozen trellis
thorn relic
#

Oh, that sounds very simple!

#

I will try this. Thanks a lot! 🙂

frozen trellis
#

No problem, glad I could help!

frozen trellis
#

Because otheriwse the update will trigger a new invoice/period for the full amount upfront

#

And 'reset' the cycle time to that moment

thorn relic
#

I can use the dashboard to set that no pro rata calculation takes place. Does this work via the API with 'proration_behavior' => 'none'?

frozen trellis
#

Yes, but it'll bill them immediately for the full amount I suspect

thorn relic
#

I'll try it. The tips are very valuable!

formal lagoonBOT
thorn relic
#

Can you have a look at this req_rOmNY9eW83zxSV

frozen trellis
#

Sure, items should be an array. Looks like you just passed an object. Can you share the code?

thorn relic
#

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'];
}

pseudo moat
#

Hi @frozen trellis I can't seem to reply in my thread. Could you authorize me to please?

frozen trellis
#

@thorn relic Should be:

 $updated_items = [[
                    'id' => $subscription['items']['data'][0]['id'],
                    'price' => $price,
                ]];
thorn relic
#

Oh, how stupid of me.

#

That looks good. It apparently worked, even without any proportional calculation. Only the price has changed. I will check the next billing using Test-Clock.

#

It works!