#ajayvibeosys-product-plan

1 messages ยท Page 1 of 1 (latest)

solar eagle
#

Do you have errors when try those API. I believe if there is active Subscription, Stripe won't let you delete those Product/Plan

warm rover
solar eagle
#

I would so don't worry, Stripe will errored out. You can test the behavior in Test mode tho

warm rover
#

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?

solar eagle
#

Yeah handle within try catch is a good idea

warm rover
#

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?

solar eagle
#

A Subscription should only have 1 price. Not sure what do you mean by dynamic

warm rover
solar eagle
#

ahhh

#

Sorry, I missed that

#

I think it should be possible ๐Ÿค” Haven't tried tho

warm rover
#

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

solar eagle
#

Hello, sorry I am a bit stretched

#

I think it should be possible, let me try

#

yes it works

warm rover
#

could you provide some code you tested?

solar eagle
#

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
})
warm rover
#

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

solar eagle
#

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

warm rover
#

oh
it can be other way too
like custome first create subscription with SMS + EMAIL
then he dont want SMS in subscription

then?

solar eagle
#

Then in the update call, you specify SMS item with its exactly Id, and deleted = true

warm rover
#

ok thanks alot for all help

solar eagle
#

You are welcome, good questions tho ๐Ÿ˜„

#

good luck 4242

warm rover
#

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?

solar eagle
#

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

warm rover
solar eagle
#

I suggest to replace planMonthly and planAnnually with 2 Price

#

Use Price API instead of Plan API