#Vinz

1 messages ยท Page 1 of 1 (latest)

fierce kilnBOT
brittle pond
#

Hi ๐Ÿ‘‹ how can we help?

half valley
#

I have an existing subscrition with products prices

#

I want to let user to update it

#

I want user to know new price (of course)

#

So I send :

        return stripe.Invoice.upcoming(  # Retrieve next invoice.
            customer=stripe_customer_id,
            subscription=stripe_subscription_id,
            subscription_items=subscription_items,
            subscription_proration_date=int(datetime.datetime.timestamp(proration_date))
        )
#

but I receive Request req_YtTmOryitdBSPh: Cannot add multiple subscription items with the same plan: price_1MWiBSIP6C7BiREF07m9

#

Or, if I delete the subscription argument : Request req_vqHle4AHIepx9N: Cannot specify proration date without specifying a subscription

#

What should I do ? I want to use proration_date to display the date of the next invoice

brittle pond
#

It sounds like you need to remove one of the duplicate Subscription Items in order for that to work. Have you tried that?

half valley
#

yep, there is no duplicate

#

in my subscription_items I have

#

and that's all

#

Any idea @brittle pond ?

brittle pond
#

Are one of those Prices already on the Subscription?

half valley
#

yes, that's my point

#

It is an update of prices existing in subscriptions

#

of quantities actually

#

I want to simulate changes

brittle pond
#

Okay, I see. let me dig a bit and circle back to you

#

So, a couple things. There error for the request mentioned above (req_YtTmOryitdBSPh) is "Cannot add multiple subscription items with the same plan: price_1MWiBSIP6C7BiREF07m9pizs". Since the Subscription you're attempting to update already has a Subscription Item with this price (price_1MWiBSIP6C7BiREF07m9pizs), you will need to change the quantity on the existing Subscription Item (see: https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription_items-quantity).

What you're doing now seems to be attempting to add a new Subscription Item with that Price (again price_1MWiBSIP6C7BiREF07m9pizs). So rather than passing:

subscription_items: { 0: { quantity: "10", price: "price_1MWiBSIP6C7BiREF07m9pizs", },

Try passing:
subscription_items: { 0: { quantity: "10", id: "si_abc123", },

where si_abc123 is the actual Subscription Item

half valley
#

wooo f*k I don't have it in DB

#

Let me ask you one more question @brittle pond

#

Do you think this is a problem I hit the stripe API each time a client hit a plus or minus button to update quantities

#

I do that in order to have consistent prices

#

And not one price in my DB and one on stripe

#

that would be double maintenance if price changes