#surajpatidar

1 messages ยท Page 1 of 1 (latest)

unkempt forgeBOT
rich garnet
#

i have try this

        items = [{
            'id': user.subscription.id,
            'price': new_plan.id,  # Switch to new price
        }]
        invoice = stripe.Invoice.upcoming(
            customer=user.customer.id,
            subscription=user.subscription.id,
            subscription_items=items,
            subscription_proration_date=proration_date,
        )```
#

but it give me error with this

wet cargo
#

Hi
You are passing a SubscriptionId to as a Subscription Item Id.

#

subscription_items[0].id=sub_1NSw11ECJUF37lWXGidcpO2r while sub_1NSw11ECJUF37lWXGidcpO2r is a Subsciprion Id and not a SubscriptionItem Id .

rich garnet
#

okay

#

i have one more question

#

if i have created this after i i want to modify susbcription so need any change or need id of this bill or not ?

wet cargo
#

I don't understand your last question. Do you have a request Id example ?

rich garnet
#

i have follow this doc for only calculate price but it change the plan why ?

wet cargo
#

Can you share a requestId ?

rich garnet
#

it give me total amount like that 20797

wet cargo
#

We need a Stripe objectID (e.g. requestId) to understand what you are trying to achieve exactly

unkempt forgeBOT
small zinc
rich garnet
#

i have't see id

#

stripe not give any logs

small zinc
#

You can find them in the Dashboard, as explained at the link

#

I need to see the exact API request you're making to understand why it's not working as you expect

rich garnet
#

i have already see in logs but not so request but it give me

#

reponse

small zinc
#

And what is the response?

rich garnet
#

"amount_due": 20795, can i show this amount user to charge new

#

i have try this

        subscription = stripe.Subscription.retrieve(user.subscription.id)
        items = [{
            'id': subscription["items"]["data"][0].id,
            'price': new_plan.id,  # Switch to new price
        }]
        invoice = stripe.Invoice.upcoming(
            customer=user.customer.id,
            subscription=user.subscription.id,
            subscription_items=items,
            subscription_proration_date=proration_date,
        )
        print(invoice)```
small zinc
#

What's the subscription.id value (sub_xxx)?

rich garnet
#

sub_1NSw11ECJUF37lWXGidcpO2r

small zinc
#

What exactly are you trying to do?

#

Preview a Subscription upgrade?

rich garnet
#

yes

small zinc
rich garnet
#

bro why it calculate downgrade request payment

small zinc
#

Looks like you're calculating the upgrade from a monthly price (price_1MxquQECJUF37lWXqBf9SptP) to a yearly price (price_1MxqvJECJUF37lWXlnQ6gzFk). What exactly is unexpected about the response?

rich garnet
#

i hava't go to year to monthy

#

i have montly platinum plan and after i have schedule for downgrade plan with gold after i am tring to calculate upgrade plan price for customer but it it calculate from gold and platnium and diamond

small zinc
#

Well, that is what that API request is calculating. You're previewing the change from a monthly price to a yearly price, with prorations applied

rich garnet
#

monthly 79 to 249

small zinc
#

Ok, I misspoke. You're right

rich garnet
#

no problem

#

if downgrade schedule request created and after that i can i will upgrade plan ?

#

or need delete downgrade request ?

small zinc
#

Which downgrade request? The Invoice.upcoming method is not making a downgrade/upgrade, it simply returns a preview of the initial invoice for what that downgrade/upgrade would cost

#

You use Subscription.modify to actually do the downgrade/upgrade

rich garnet
#

okay i understand all thing

#

but today i purchese 79$ plan

#

after i have submit request for down grade is 39$ so i have use this logic

                    start_date = user.subscription.schedule.current_phase['start_date']
                    stripe.SubscriptionSchedule.modify(
                        user.subscription.schedule.id,
                        phases=[
                            {'items':
                                [
                                    {
                                        'price': current_plan.id,
                                        'quantity': 1,
                                    }
                                ],
                                'end_date': end_date,
                                'start_date': start_date,
                            },

                            {'items':
                                [
                                    {
                                        'price': new_plan.id,
                                        'quantity': 1,
                                    }
                                ],
                                'start_date': end_date,
                                'iterations': 1,
                                'billing_cycle_anchor': 'phase_start',
                            },

                        ],
                    )
#

now i previewing for 79$ to 249 but already income invoice created because i have submited down grade request

#

now in previewing it calculate price from 79$ and 249$ with 39$

#

but i need only calculate from 79$ to 249$

#

i have send reponse in message.txt

small zinc
#

It's because the Schedule that controls sub_1NSw11ECJUF37lWXGidcpO2r has the 'Gold' plan in an upcoming phase

rich garnet
#

so my question is can we need to delete this schedule first and after go with upgrade

small zinc
#

So the upcoming invoice preview will be previewing the next billing period, where that phase will be applied

small zinc
rich garnet
#

so i need first delete this schedule and after i will upgrade with new 249

rich garnet
small zinc
#

The Subscription will be released from control of the Schedule

rich garnet
#

and continue 79 plan right ?

small zinc
#

Yes

rich garnet
#

after that if i upgrade with 79 to 249 it calculate this both price for previwing right ?

small zinc
#

It should do yes

rich garnet
#

okay

#

one more problem

small zinc
#

Sure

rich garnet
#

but it cost more why

#

when we give price like that 79x100
so now stripe give this amount how to caluclate in doller ?

#

bcz it show "amount_due": 41780,

small zinc
#

The amount will always be in cents, so you'd divide by 100

rich garnet
#

41780/100 right ?

small zinc
#

Yep!

rich garnet
#

so it charge 417 why bro

#

new_price in doller only 249

#

it show new charge is 417 why

small zinc
#

Looks like there are 2 items on the Subscription for the 'Diamond' plan

rich garnet
#

no

small zinc
#

Check the lines list on the response for a breakdown

rich garnet
#

i have only one dimond plan for

#

it show

        "amount": -7845,
        "amount_excluding_tax": -7845,
        "currency": "usd",
        "description": "Unused time on Platinum after 12 Jul 2023",
        "discount_amounts": [],
        "discountable": false,
        "discounts": [],
        "id": "il_tmp_163c60ECJUF37lWX08a04319",
        "invoice_item": "ii_1NT0uXECJUF37lWXPk3zqrS8",
        "livemode": false,
        "metadata": {},
        "object": "line_item",
        "period": {
          "end": 1691819707,
          "start": 1689160093
        },````
#
        "amount": 24725,
        "amount_excluding_tax": 24725,
        "currency": "usd",
        "description": "Remaining time on Diamond after 12 Jul 2023",
        "discount_amounts": [],
        "discountable": false,
        "discounts": [],
        "id": "il_tmp_1bb5b6ECJUF37lWX762e0baf",
        "invoice_item": "ii_1NT0uXECJUF37lWX75Bh0lZ9",
        "livemode": false,
        "metadata": {},
        "object": "line_item",
        "period": {
          "end": 1691819707,
          "start": 1689160093
        },```
#
        "amount": 24900,
        "amount_excluding_tax": 24900,
        "currency": "usd",
        "description": "1 \u00d7 Diamond (at $249.00 / month)",
        "discount_amounts": [],
        "discountable": true,
        "discounts": [],
        "id": "il_tmp_174e29ECJUF37lWX4b3bfc02",
        "livemode": false,
        "metadata": {
          "referral_id": "None",
          "user_email": "suraj@suraj.com"
        },
        "object": "line_item",
        "period": {
          "end": 1694498107,
          "start": 1691819707
        },```
small zinc
#

Yup, as I said 2 items for the Diamond plan. One is prorated as per the parameter you're passing to the endpoint

rich garnet
#

So how to remove this one

#

Because I need only this month calculation

small zinc
#

Then you ned to disable proration when you preview the change

rich garnet
#

I have try this one

small zinc
#

And what was the outcome? I suspect it's because in your request currently you're backdating the prorations

rich garnet
#

Bro how to disable need to add parameter or remove existing parameter

#

i have try this

        subscription = stripe.Subscription.retrieve(user.subscription.id)
        items = [{
            'id': subscription["items"]["data"][0].id,
            'price': new_plan.id,  # Switch to new price
        }]
        invoice = stripe.Invoice.upcoming(
            customer=user.customer.id,
            subscription=user.subscription.id,
            subscription_items=items,
            subscription_proration_date=proration_date,
        )
#

Need to add parameter or delete from existing

small zinc
#

You need to add subscription_proration_behavior="none"

rich garnet
#

Okay

#

I will try

#

stripe.error.InvalidRequestError: Request req_1CjDwdY71pZiCi: Cannot specify proration date if no proration is being done

#

it give this error

drowsy kiln
#

Hi! I'm taking over this thread.

#

Give me a few minutes to catchup

rich garnet
#

stripe.error.InvalidRequestError: Request req_LikvhXijhAHVKh: Cannot specify proration date if no proration is being done

drowsy kiln
#

You passed both subscription_proration_behavior: "none" and subscription_proration_date, which is not possible. What are you trying to do?

#

If there are no prorations, just remove subscription_proration_date.

rich garnet
drowsy kiln
#

You should either pass subscription_proration_behavior="none" and don't pass subscription_proration_date, or do the opposite.

#

It doesn't make sense to ask for no prorations but still pass a proration date.

rich garnet
#

please give how to calulate price if i will upgrade

#

this suggest by @small zinc

#

i want to calculate price if i upgrade how me extra need to pay ?

#

give me best way for that part

drowsy kiln
#

Remove subscription_proration_behavior="none"

rich garnet
#

okay

#

but now ti give price "total": 41757,

#

and this price high

#

it give after divide 417$

#

and it not righ because i upgrade from 79 to 249

#

right ander should be 168 something

#

hii

drowsy kiln
#

Sorry for the delay

#

Can you share the JSON response you got, and what you were expecting to see instead?

rich garnet
#

yes

#

i will upgrade from 79 to 249 so extra charge shoude be 168 around

#

but it give 417 extra

drowsy kiln
#

The upcoming invoice is a preview of the next invoice. That means it contains both the proration items for the change you make and also the amount for the next invoice. To only see the proration, you have to inspect the lines of the upcoming invoice and only sum up the ones that are marked proration:true.

rich garnet
#

Need any parameter change or do with my self

drowsy kiln
#

That's something you have to do yourself.