#jennifer_best-practices

1 messages ¡ Page 1 of 1 (latest)

remote novaBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1245681935024656507

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

balmy sable
#

my code:
schedule = stripe.SubscriptionSchedule.create(from_subscription=stripe_current_sub_id,) updated_schedule = stripe.SubscriptionSchedule.modify( schedule.id, phases=[ { 'items': [{ 'price': schedule.phases[0].items[0].price, 'quantity': schedule.phases[0].items[0].quantity, }], 'start_date': schedule.phases[0].start_date, 'end_date': schedule.phases[0].end_date, }, { 'items': [{ # 'id': schedule.phases[0].items[0].id, 'price': new_price_id, 'quantity': 1, }], 'iterations': 1, }, ], )

weary tiger
#

hi! do you know which exact line is throwing that error?

#

also if you remove the , from from_subscription=stripe_current_sub_id,) on the first line, does that help?

balmy sable
#

i tried without comma, modify method gave same answer

weary tiger
#

ok well give me a while to try and replicate this.

#

it's Python right?

balmy sable
#

ok thank you, yes python 3.9

#

and stripe stripe 9.4.0

weary tiger
#

you have to replace .items with ['items'] like this

'price': schedule.phases[0]['items'][0].price,
on every place it's used

#
updated_schedule = stripe.SubscriptionSchedule.modify(
    schedule.id,
    phases=[
        {
            'items': [{
                'price': schedule.phases[0]['items'][0].price,
                'quantity': schedule.phases[0]['items'][0].quantity,
            }],
            'start_date': schedule.phases[0].start_date,
            'end_date': schedule.phases[0].end_date,
        },
        {
            'items': [{
                # 'id': schedule.phases[0]['items'][0].id,
                'price': 'price_xxx',
                'quantity': 1,
            }],
            'iterations': 1,
        },
    ],
)