#iamshubhamaratha
1 messages · Page 1 of 1 (latest)
hello! if you update an existing subscription using that endpoint, it won't navigate to any checkout page for paying the remaining amount. Assume you're using collection_method=charge_automatically, then it will deduct the amount from the customer's card
and if the user wants that the payment should not be done automatically, it should be done manually how can we handle that case
Hi @dry sparrow I am waiting for your response
if you want payments to be done manually, then you can use collection_method=send_invoice
okay
and if the payment is done automatically, in stripe where I can find that the payment has been successfully or not and subscription has been updated to not because current I am using the https://stripe.com/docs/api/subscriptions/update#update_subscription-items but after the success I am unable to see the payment in stripe payment tabs
could you please help me with this please?
do you mean if you update a subscription with charge_automatically, how do you know if the payment is successful and the subscription has been updated?
yes
so if you're using charge_automatically, you would want to use payment_behavior=pending_if_incomplete : https://stripe.com/docs/billing/subscriptions/pending-updates
if the payment is successful, the subscription would be updated. You can listen for the customer.subscription.pending_update_applied - https://stripe.com/docs/billing/subscriptions/pending-updates-reference#events
Hi subscription with charge_automatically in this how can we generate invoice , I am unable to see any invoice
also, how can we see how much amount has been deducted in the stripe portal in case of updating subscription
did you include proration_behavior=always_invoice when creating the update : https://stripe.com/docs/api/subscriptions/update#update_subscription-proration_behavior?
https://stripe.com/docs/billing/subscriptions/upgrade-downgrade - you may want to take a look at this too
yes I have used always_invoice
how much amount has been deducted in the stripe portal - what do you mean by stripe portal? Do you mean the customer portal?
can you share your request id?
I mean suppose the user has subscribed for a product in which he has been charged 20 $ for 3 items now he has been updated the quantity from 3 to 8, so in that case, how can we show to the user that this much amount has been deducted automatically and also in stipe where we can see that how much amount has been charged on that subscription in case of update
have you done this update? if you have, can you share the subscription or request id? it'll be easier for me to point you to where you can see it
yes I have done change now I am able to see the invoice
can you please help me with that how can I show how much amount has been deducted automatically in UI in case of an update, because as a user he needs to know that this much amount will deduct automatically if he updates the subscripn
https://stripe.com/docs/billing/invoices/subscription#previewing
https://stripe.com/docs/api/invoices/upcoming
you can preview the changes using the above API and display them to the user. Otherwise, maybe a better alternative would be to let your customer upgrade/down subscriptions using the customer portal : https://stripe.com/docs/customer-management
got it
Hi Team, suppose the user has subscribed for a product in which he has been charged 8 $ for 2 items now he has updated the quantity from 2 to 4, so in that case, how can we show to the user how much amount has been deducted automatically instantly if a user is going to update there subscripiotn
Hi @fresh stirrup can you please help me with the query
Hey!
You'd use this endpoint to generate a 'preview' invoice of the proposed changes: https://stripe.com/docs/api/invoices/upcoming
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Hi @fresh stirrup this will help me to generate the invoice for the next month
You want to show a preview of an invoice/amount if the user is considering an upgrade, correct?
correct
For example: suppose you are the user and you have subscribed for a product in which you have been charged 8$ for 2 items now you have updated the quantity from 2 to 4, so in that case, you need to see in the UI that how much amount has been deducted automatically instantly if you are going to upgrade.
Then that is the correct endpoint to use. You need to pass subscription_items to reflect the upgrade you want to make
okay let me try then
Hi @fresh stirrup , it is showing me the amount which is going to charge after the update, if we go with the example: it shows me the amount of 4 items which is going to charge next month, but I am unable to find the amount which is going to charge instantly
it need to show that data in json but it not showing that data
What data?
like remaing time , unused time and after there subtraction of those two the amount which is going to charge
currently, that endpoint is returning the data for this section
You'll need to parse the JSON returned to build that UI yourself. All the data you'd need for that would be included on the Line Item object(s): https://stripe.com/docs/api/invoices/line_item
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
👋 taking over for my colleague. Let me catch up.
these are the files I am unable to see remaing time , unused time values
you can calculate those based on the period.start and period.end
period.start and end is a time stamp
I need to the value of these highlighted section
the info you're asking about is found under lines
in lines it is showing me the value of remaining time, but not unused time
how would I get the unused time value as well in same endpoint
would you mind sharing the request ids where you generated these results
req_2vnuMMvGgx2i78
sorry I'm still looking into this
yes that's what I figured
there was no proration
I'm still not sure why
maybe I'm missing something obvious
sorry where did you get the objects from?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
using this
so that's not the request that you sent me earlier
this is the same request I guess
#1027462364318154753 message this one I have copied from stripe portal
no the one you sent it's actually you making a subscription upgrade and not trying to get upcoming invoice
it's a POST request whereas upcoming invoice is a GET request
see we are getting confused over there
again I am explaining you
For example: suppose you are the user and you have subscribed for a product in which you have been charged 8$ for 2 items now you have updated the quantity from 2 to 4, so in that case, you need to see in the UI that how much amount has been deducted automatically instantly if you are going to upgrade.
As a user, you need to see the amount which is going to deduct, and if I am not showing that amount before the deduction it is not a good apprach
I understand but I would need to see which parameters you provided the upcoming invoices API to know why it generated the upcoming invoice without prorations
would you mind sharing the request id for that request that generated the JSON response you shared earlier?
var options = new UpcomingInvoiceOptions
{
Customer = customerId,
SubscriptionItems = new List<InvoiceSubscriptionItemOptions>() {
new InvoiceSubscriptionItemOptions(){
Quantity = 6,
Plan = "adfa5454_USD"
}
}
};
you haven't specified a subscription id here
so there is no prorations to be calculated
okay , let me try this is as well
could you please let me know where do I need to pass the subsctionId
in the UpcomingInvoiceOptions
UpcomingInvoiceOptions.Subscription
now I am able to get the data but why I am getting amount like "amount": 2391,
in what formate the amount is coming
it's an integer of the smallest unit of the currency being used.
so if it is currency:"USD" then that is 2,391 US cents, which is $23.91 (~24 dollars).
got it
Hi the value which I want is coming but the sub total value is not matching correctly with invoice
Unused time = [ "amount": -2388,
"amount_excluding_tax": -2388,
"currency": "usd",
"description": "Unused time on 6 × Anywhere after 06 Oct 2022",]
Remaining time = [ "amount": 3184,
"amount_excluding_tax": 3184,
"currency": "usd",
"description": "Remaining time on 8 × Anywhere after 06 Oct 2022",
]
and sub total and total which I have get in same JSON is ["subtotal": 3996,
"subtotal_excluding_tax": 3996,
"tax": null,
"test_clock": null,
"total": 3996,
"total_discount_amounts": [],
"total_excluding_tax": 3996,
]
the above data I generated before the subscription update
now for verify the result I have completed the update subscription and found that sub total is not correct
Hi @vivid badger please help with this
not understanding you, sorry. Can you clearly state what you expected to see, what you saw instead, and why you expect that?
I want that subtotal in JSON should be the same as it is showing in the invoice, if we convert 3996 cents is equal to 39 dollars not 7 dollers
so if you can see on the screenshot used time value is correct matching with [ "amount": -2388,
"amount_excluding_tax": -2388,
"currency": "usd",
"description": "Unused time on 6 × Anywhere after 06 Oct 2022",]
And Remaining time value is also is correct matching with [ "amount": 3184,
"amount_excluding_tax": 3184,
"currency": "usd",
"description": "Remaining time on 8 × Anywhere after 06 Oct 2022",
]
but the subtotal value is different in not matching with this ["subtotal": 3996,
"subtotal_excluding_tax": 3996,
"tax": null,
"test_clock": null,
"total": 3996,
"total_discount_amounts": [],
"total_excluding_tax": 3996,
]
where did your JSON from exactly? What API calls and code?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
from this
no
what code did you write exactly and what are all the specific IDs like the subscription ID sub_xxx and invoice in_xxx and request IDs https://support.stripe.com/questions/finding-the-id-for-an-api-request
I'd suggest taking some time to collect that information and write a clear summary of your problem, otherwise it's impossible for us to help really.
see the problem is simple I need the invoice data which is getting generated after the subsection upgrade , but this data is required before user can processed for subscription update
not after the subscription update
yep, that's our "previewing prorations" feature, we do know about it. https://stripe.com/docs/billing/subscriptions/prorations#preview-proration
unfortunately it's hard to help you without a clear summary and hours of conversation
I'd suggest taking some time to summarise your issue and thinking about it and coming back with a detailed question with all the information I asked for.
this is the invoice which is going to generate when the user has completed their subscription upddate
I need that data
sorry but you're not reading what I wrote.
I have read all the things and since morning I am providing all the details
which you guys are asking
my question in not really hard
I have already given other two guys live exmaple
as well
what code did you write exactly and what are all the specific IDs like the subscription ID sub_xxx and invoice in_xxx and request IDs https://support.stripe.com/questions/finding-the-id-for-an-api-request
this conversation won't work I'm afraid
var options = new UpcomingInvoiceOptions
{
Subscription = subscriptionService.Id,
Customer = customerId,
SubscriptionItems = new List<InvoiceSubscriptionItemOptions>() {
new InvoiceSubscriptionItemOptions(){
Quantity = userCount,
Plan = subscriptionService.Items.Data[0].Plan.Id,
Id = subscriptionService.Items.Data[0].Id,
}
}
};
this is the code which I have wrote
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
this was the endpoint
that's not the exact response, that's a snippet of it.
what was the exact full response?
got it
so that Invoice shows what the next invoice for the subscription would look like if you made the changes you pass to UpcomingInvoiceOptions, at the exact time that you pass them.
do you have a question about that response?
the invoice screen shot which I have shared is the invoice which is generated once user has upgrade the subscription and the JSON which I have shared is getting before updating
now could you please help to get the values for JSON which maps with invoice screenshot
ok stop for a second
re-read what I said above :
would look like if you made the changes you pass to UpcomingInvoiceOptions, at the exact time that you pass them.
so say you have a subscription from Oct 1->Nov 1 for $100
On Oct 6th, you call that UpcomingInvoice endpoint. We calculate proration at that point in time. Let's say the prorated amount is $90.
On Oct 7th, you actually call the SubscriptionUpdate endpoint. We calculate proration at that point in time. Let's say the prorated amount is $85.
so that is one reason why your amounts might not match. If you read https://stripe.com/docs/billing/subscriptions/prorations#preview-proration is specifically covers this and describes how you use the API to make sure the amounts match:
Because Stripe prorates to the second, prorated amounts can change between the time they’re previewed and the time the update is made. To avoid this, pass in a subscription_proration_date to the invoice when you preview a change. When you update the subscription, you can pass the same date using the proration_date parameter on a subscription so that the proration is calculated at the same time.
beyond that, the amount on the actual invoice might not match the one in the upcoming invoice if you're not actually passing the same update parameters (the same Price and quantity for example) when you call UpcomingInvoice and SubscriptionUpdate. So that's something else for you to check.
@thin stratus that does all make sense and give you enough information to go and investigate your code and set up?
so If the day is the same but the time is different does it also affect the amounts which is not matching
and if we do not pass SubscriptionProrationDate what time it is going to pick it is UTC or server time zone
yes. Per the docs I linked and quoted:
Because Stripe prorates to the second .
not by day, by second. So any time difference changes the amount.
it's nothing to do with timezone whatsoever, sorry but you don't understand it
we just use the current time and compare it to the time (the billing_cycle_anchor for example) your subscription's periods are for.
I am understanding but still have a question
what's the question @thin stratus ?
is it possible to jump on the call ?
it is not
var options = new UpcomingInvoiceOptions
{
Subscription = subId,
Customer = customerId,
SubscriptionItems = new List<InvoiceSubscriptionItemOptions>() {
new InvoiceSubscriptionItemOptions(){
Quantity = userCount,
Plan = planId,
Id = subItemId,
}
},
SubscriptionProrationDate = DateTimeOffset.UtcNow.UtcDateTime
};
no I am passing all the things correctly
but still the amount is not same
this is invoice data
can you share the URL of the page where you took this screenshot please?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
that page is just a list of invoices, so that's not correct.
can you share the URL of the page where you took this screenshot please?
thanks
looking.
when you updated the subscription (https://dashboard.stripe.com/test/logs/req_ZFz13AG6zb7oFl) to generate the invoice, you did not pass proration_date.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
so that will prorate based on the current time. Again, going back to the quoted docs:
To avoid this, pass in a subscription_proration_date to the invoice when you preview a change. When you update the subscription, you can pass the same date using the proration_date parameter on a subscription so that the proration is calculated at the same time.
you have to change the code that calls UpcomingInvoice, and the code that calls Subscription.Update. Is that clear @thin stratus ?
no both are diffrenet methods
I have created a separate API for UpcomingInvoice & Subscription.Update.
well you'll have to make it work really
if you want them to match you have to do what the docs say. When calling UpcomingInvoice , you need to pass a subscription_proration_date: <SOME SPECIFIC TIME X>. When calling Subscription.Update, you need to pass proration_date: <SOME SPECIFIC TIME X>
both API are separated there in no property called "**proration_date **" event in the docs
okay wait
not sure what you're talking about.
https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription_proration_date
https://stripe.com/docs/api/subscriptions/update#update_subscription-proration_date
they're right there.
I have added proration_date in both the api's now I am checking again
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
here is the log I have passed the proration_date in it
cool. Did you have a question?
now I am passing all the things correctly but still SubTotal is not matching with invoice screen shot
you're not passing them correctly.
https://dashboard.stripe.com/test/logs/req_lTbfGfCdwPjVfF you passed subscription_proration_date: "1665060226",
https://dashboard.stripe.com/test/logs/req_OoCL9uwkoF2QIz you passed proration_date: "1665060310",
those are not the same timestamps.
what you probably did is you got Date.now() or something in both parts of your code and passed that, which would be wrong. Again, docs :
To avoid this, pass in a subscription_proration_date to the invoice when you preview a change. When you update the subscription, you can pass **__the same date __**using the proration_date parameter on a subscription so that the proration is calculated at the same time.
@vivid badger as user it will take time to see the amount
user will take time to see the amount
what was the previous and what was the current amount
how would we suppose that it will not delay a second or min
generally you pick a time. So for example the customer visits your site and wants to update. You say "if you update, we'll calculate the change at midnight tonight" (or something else, like you pick 'current time + 1 hour'), and you pass the timestamp for that to both the preview and update endpoints.
all good @thin stratus [oops]
is is possible to create techincal call setup
it is not no
you had 7 hours of my team's time, all day today
in any case, we don't offer calls.
if you have specific questions feel free to ask them here or email https://support.stripe.com/?contact=true
how can we create techinal ticket
@thin stratus shall we stop here? I have been helping you for 2 hours now and it's my lunch break, and for you I believe it's later in the evening? Going to close this thread.
you write to https://support.stripe.com/?contact=true
I suggest you spend time this evening/tomorrow re-reading everything and doing some testing and experimentation. If you have still have questions, you can ask them later, with specific details like exact code and object IDs(subscription sub_xxx; invoice in_xxx etc) and clear summaries.
I do not know how many times you guys need my code in past 8 hours I am just typing the queries and providing the details to you guys but the result is 0
you can close the chat if you want