#sarvesh3742_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ 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.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ 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/1379437348202217582
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
๐ happy to help
Subscription API - 2 plans $10/month & $100/month are created and user subscribed but now $100 changed to $80 by creating new price obj, but old users are still paying $100. how to fix it
Related Request ID(s)
Stripe Subscriptions API
What have you already attempted?
first I want to get info about which approach to follow to fix it.
What are you working on?
PHP Stripe APIs
you need to update all subscriptions that were using the old price to now use the new price
ok, so we need to retrive the all users subscription from subscription_id and update that object with new price id?
you need to retrieve all subscriptions that have the old price and update them yes
when we update the plan price from web admin, can we update existing subscription plan on Stripe with new price instead of create new price obect and which can save work of again we need to retrive all existing users subscribed for it and update them?
If we can change the price directly for the plan then no more efforts needed and all new/old both will get same price from next billing cycle
hey there, stepping in for tarzan who had to head out
can we update existing subscription plan on Stripe with new price instead of create new price obect and which can save work of again we need to retrive all existing users subscribed for it and update them
you can upgrade/change subscription prices on the Dashboard, yes, but it works the same way effectively. you load up a single customer/subscription and make changes to it (ie, replace the price). If you have many subscriptions to update to new prices, the best way is using a script you write to do this. If you have hundreds/thousands+ of subs to update you'll likely also need to take rate limiting into account and throttle your update requests.
No we have one plan which price initially was say $100 and 10 users already subscribed that plan, After that from website admin area, admin has edited that plan and make it to $80, so while editing we created new price object in same plan and new users are subscribed with $80 but old one are still paying the $100 and we do not want that. So here instead of creating new price obect, can we just update the existing price object on Stipe to change $100 to $80 so from next billing all new / old both users will get charged for $80. Is this possible?
below is code for your understanding, it will be good if you can suggest what we need to change
if(!empty($planData[0]['stripe_product_id'])) {
$projectData = $stripe->products->update($planData[0]['stripe_product_id'],[
'name' => $plan_name,
'active' =>$status,
]);
$priceData = $stripe->prices->update($planData[0]['stripe_price_id'],['metadata' => [
'active' =>$status,
'unit_amount' => $price,
'currency' => 'usd',
'product' => $projectData->id,
]]);
$priceDataId = $priceData->id;
$projectDataId = $projectData->id;
$stripe_response =json_encode($priceData,true);
} elseif(empty($planData[0]['stripe_product_id']) && $is_active == 1 ) {
$projectData = $stripe->products->create([
'name' => $plan_name,
'active'=>$status,
]);
$priceData = $stripe->prices->create([
'active' =>$status,
'unit_amount' => $price,
'currency' => 'usd',
'recurring' => ['interval' => 'month'],
'product' => $projectData->id,
]);
$priceDataId = $priceData->id;
$projectDataId = $projectData->id;
$stripe_response = json_encode($priceData,true);
}
So here instead of creating new price obect, can we just update the existing price object on Stipe to change $100 to $80 so from next billing all new / old both users will get charged for $80. Is this possible?
no, that's not possible. Prices are immutable once created, you can only change the amount by creating a new price, for exactly this reason.
The prices must remain intact both for existing subscriptions and also for past payments to align
You change the amount charged to customers, you have to update the subscription to set the new price on the item
ok, so whoever users have subscribed with old price, we need to retrive them with subscription Id and update their subscription with new price object id, whenever pricing is getting changed from our website admin area?
can we change the new price id by login to Stirpe dashboard and edit existing user subscriptions manually? if those are less in numbers?
yes, if you want them to get the new pricing. Also be aware of prorations and how you want the new price to apply (right away prorated vs deferred until next renewal etc).
Yes, you can update the price on existing subscriptions in the dashboard