#bugkiller-subscription-quantity

1 messages · Page 1 of 1 (latest)

old flaxBOT
long grove
#

Hello what is your question?

stuck solar
#

hi, thanks for coming back to me.

#

I'm going to create a subscription in our system

#

we already have a plan created in stripe dashboard

#

when I create a subscription, I want to use the parameter items.quantity

#

my question is is it ok to not specify item.price?

#

it will automatically calculated because price is in plan

#

Am I right?

violet comet
#

bugkiller-subscription-quantity

#

@stuck solar The Plan API is deprecated and replaced by Price. So mostly when you create a Subscription you pass both price and quantity really

stuck solar
#

plan api?

#

I'm saying about this api

violet comet
#

That API is the Create Subscription API. It takes items as a parameter which itself has price as a parameter. You have to pass the price parameter

stuck solar
#

when I read the documentation, it's optional

#

so I'm asking here to know exaclty

violet comet
#

you have to pass it, ignore what the documentation says, it's incorrect

stuck solar
#

wow

violet comet
#

basically you have to pass price. But you can pass price_data instead

#

so one of the two is required, which makes both optional technically

stuck solar
#

I'v succeeded without passing this 2 parameters when I don't use items.quantity

#

but now I'm trying to use quantity (due to requirements) , so asked for check.

#

maybe I need to check myself by testing a little bit.

#

if I need to provide it, price should be total amount?

#

or just 1 item price?

violet comet
#

I'm sorry but none of this is really clear. The Price id is always required, whether you pass quantity or not. I need you to provide a lot more actionable information, all in one messages (not many sequential short sentences) that describes what you are doing, your exact code, which error you get, clear request ids (req_123) and examples where it worked before (sub_123) so that I can help you

stuck solar
#

I'm using python so I"m calling like

#

python library stripe provide

#
stripe.Subscription.create(customer=stripe_customer.id, trial_from_plan=trial_from_plan, coupon=coupon_code, items=[{'plan': product_code}])
violet comet
#

yeah so you're using a multi-year old deprecated parameter. That's what I meant earlier. The Plan API has been deprecated by Price. You used to pass plan: 'my plan' and now you want to pass quantity: 10. You can add this, but I'd recommend also switch away from plan and passing price so simply stripe.Subscription.create( customer=stripe_customer.id, trial_from_plan=trial_from_plan, coupon=coupon_code, items=[ { 'price': product_code, quantity: 10, }, ], )

stuck solar
#

that means I need to upgrade stripe library (for python)?

#

I'm afraid if it will break my existing codebase

violet comet
#

no

#

ultimately it's fine, keep plan, just add quantity, there won't be any issue

stuck solar
#

what about upgrading the library?

#

my library is 2.56

#

maybe current is 5.0

violet comet
#

you just said you were worried so I'm side stepping that

stuck solar
#

ok. that means upgrading library could break something not work?

#

thanks for providing me a link. let me check

violet comet
#

sounds good

stuck solar
#

so it should work if I provide 'plan' and 'quantity'?

#

without upgrading for now..

violet comet
#

yes

stuck solar
#

cool, then I'll try with it. and later will update

#

If I don't pass the quantity it should be 1 by default?