#surajpatidar
1 messages ยท Page 1 of 1 (latest)
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
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 .
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 ?
I don't understand your last question. Do you have a request Id example ?
i have follow this doc for only calculate price but it change the plan why ?
Can you share a requestId ?
it give me total amount like that 20797
We need a Stripe objectID (e.g. requestId) to understand what you are trying to achieve exactly
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
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
And what is the response?
"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)```
What's the subscription.id value (sub_xxx)?
sub_1NSw11ECJUF37lWXGidcpO2r
Ok, I guess this is the API request: https://dashboard.stripe.com/test/logs/req_MNrT7m29VJRvLa
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
bro why it calculate downgrade request payment
yes
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?
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
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
now i previewing from monthly platinum to montly diamond
monthly 79 to 249
Ok, I misspoke. You're right
no problem
if downgrade schedule request created and after that i can i will upgrade plan ?
or need delete downgrade request ?
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
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
It's because the Schedule that controls sub_1NSw11ECJUF37lWXGidcpO2r has the 'Gold' plan in an upcoming phase
so my question is can we need to delete this schedule first and after go with upgrade
So the upcoming invoice preview will be previewing the next billing period, where that phase will be applied
yes
You'd 'release' the Schedule: https://stripe.com/docs/api/subscription_schedules/release
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
so i need first delete this schedule and after i will upgrade with new 249
in release what happed pleasea tell me
The Subscription will be released from control of the Schedule
and continue 79 plan right ?
Yes
after that if i upgrade with 79 to 249 it calculate this both price for previwing right ?
It should do yes
Sure
it give me this respone to 79 to 249
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,
The amount will always be in cents, so you'd divide by 100
41780/100 right ?
Yep!
so it charge 417 why bro
new_price in doller only 249
it show new charge is 417 why
Looks like there are 2 items on the Subscription for the 'Diamond' plan
no
Check the lines list on the response for a breakdown
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
},```
Yup, as I said 2 items for the Diamond plan. One is prorated as per the parameter you're passing to the endpoint
Then you ned to disable proration when you preview the change
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I have try this one
And what was the outcome? I suspect it's because in your request currently you're backdating the prorations
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
You need to add subscription_proration_behavior="none"
Okay
I will try
stripe.error.InvalidRequestError: Request req_1CjDwdY71pZiCi: Cannot specify proration date if no proration is being done
it give this error
stripe.error.InvalidRequestError: Request req_LikvhXijhAHVKh: Cannot specify proration date if no proration is being done
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.
i want to culculate price of if i upgrade today how much need to pay ?
invoice = stripe.Invoice.upcoming(
customer=user.customer.id,
subscription=user.subscription.id,
subscription_items=items,
subscription_proration_date=proration_date,
subscription_proration_behavior="none",
)
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.
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
Remove subscription_proration_behavior="none"
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
Sorry for the delay
Can you share the JSON response you got, and what you were expecting to see instead?
yes
i will upgrade from 79 to 249 so extra charge shoude be 168 around
but it give 417 extra
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.
Need any parameter change or do with my self
That's something you have to do yourself.