Reputation: 51
I am working on a SAAS project where users can create various projects. With each project, they can choose from 5 different plans. Each plan has its own costs per month. Hotjar is a kind of equal concept.
Now I want to arrange the subscription with Stripe. The problem with that was that a user can have a maximum x subscription, which of course was a shame. Then I decided to take 1 subscription that has several plans. But now I have a dilemma, to update the subscription you have to change the number via SubscriptionItem. Then you have to save yourself which plan has which SubscriptionItem_id for which user. That is quite a detour and can cause many problems.
Someone is a better way with Stripe or another payment software.
Upvotes: 2
Views: 648
Reputation: 2345
You don't necessarily need to store the subscritpion_item
IDs, you can look it up via the subscription_item list API. All you need to do is store the subscription_id
for your customers, and based on that ID you can retrieve the list of subscription_items:
\Stripe\Stripe::setApiKey("sk_test_9GavlLpfiKewqeCBXvRvmVgd");
\Stripe\SubscriptionItem::all(["subscription" => "sub_EQlPGjVj4o5luH"]);
Then you can handle the data
part of the returned JSON object and update / delete / etc these subscription items.
If you only have the customer_id
handy, then you can use the subscription list API (with status as well on the GET params) to retrieve the list of active subscriptions.
Upvotes: 2