#ajayvibeosys-product-plan
1 messages ยท Page 1 of 1 (latest)
Do you have errors when try those API. I believe if there is active Subscription, Stripe won't let you delete those Product/Plan
thats what I want to achieve
before api hit
https://stripe.com/docs/api/plans/delete
I want check if it has no any active subscriptions
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I would so don't worry, Stripe will errored out. You can test the behavior in Test mode tho
you mean I must use delete plan api
and handle that in try catch
and if stripe gives error need change according to my backend?
Yeah handle within try catch is a good idea
ok thank you
consider I create products with
SMS - $1/month and $10/year
EMAIL - $2/month and $18/year
Now I want create dynamic subscription with adding above 2 product into it
but give free trial of 10 days
is it possible?
A Subscription should only have 1 price. Not sure what do you mean by dynamic
I have few products
I want to take products as user selected and make new subscription
but dont know about trial period as its for price/plan?
so any update?
or someone else from your team will guide
Hello, sorry I am a bit stretched
I think it should be possible, let me try
yes it works
could you provide some code you tested?
I used Ruby, not sure if it helps
For example
subscription = Stripe::Subscription.create({
customer: 'cus_KbAqZW6l8MpA93',
items: [
{
price: 'price_1K8ymREmaib10qkRq7FQV1kU',
},
{
price: 'price_1KJw4eEmaib10qkRftrHJcq9',
quantity: 2,
},
],
trial_period_days: 3
})
thanks for code example
I will check soon
again question on it
consider I create products with
SMS - $1/month and $10/year
EMAIL - $2/month and $18/year
and user selected SMS only
so my subscription is now have only 1 product ie. SMS
suppose user now want upgrade subscription (SMS + EMAIL)
so I need create again new subscription right?
and get old subscription
$subscription = \Stripe\Subscription::retrieve('sub_xxx');
\Stripe\Subscription::update('sub_xxx', [
I am confused
How to create new subscription with multiple products and upgrade user to it
Let's say you have a first subscription with SMS
you can simply update it, using the Update Subscription API, and specify EMAIL price in the Update call
It will results in a Subscription contains both SMS and EMAIL
oh
it can be other way too
like custome first create subscription with SMS + EMAIL
then he dont want SMS in subscription
then?
Then in the update call, you specify SMS item with its exactly Id, and deleted = true
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok thanks alot for all help
last question
as you show this code example
trial days are added in subscription create api
so no need trial days add in price/plan create api right? and that uselsess too?
and is it possible after create subscription change trial days too?
like initially I create subscription with SMS and trial days 10
1 user subscribed to it and after 10 days his amount deducted
now I want change trial days for same subscription from 10 to 15
so from now new customer subscription will get 15 days correct?
Please specify trial in Subscription creation instead of Plan creation. Plan is an old API
when you create a new Subscription for new customer, simply specify trial_days to 15
Subscriptions is separated objects per customers
but am I doing correct?
$product = $stripe->products->create([
$planMonthly = $stripe->plans->create([
$planAnually = $stripe->plans->create([
