#iamshubhamaratha

1 messages · Page 1 of 1 (latest)

nova sirenBOT
dry sparrow
#

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

thin stratus
#

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

dry sparrow
#

if you want payments to be done manually, then you can use collection_method=send_invoice

thin stratus
#

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?

dry sparrow
#

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?

thin stratus
#

yes

dry sparrow
thin stratus
#

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

dry sparrow
thin stratus
#

yes I have used always_invoice

dry sparrow
#

how much amount has been deducted in the stripe portal - what do you mean by stripe portal? Do you mean the customer portal?

dry sparrow
thin stratus
#

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

dry sparrow
#

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

thin stratus
#

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

dry sparrow
thin stratus
#

got it

thin stratus
#

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

fresh stirrup
#

Hey!

thin stratus
#

Hi @fresh stirrup this will help me to generate the invoice for the next month

fresh stirrup
#

You want to show a preview of an invoice/amount if the user is considering an upgrade, correct?

thin stratus
#

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.

fresh stirrup
#

Then that is the correct endpoint to use. You need to pass subscription_items to reflect the upgrade you want to make

thin stratus
#

okay let me try then

thin stratus
#

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

fresh stirrup
#

What data?

thin stratus
#

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

fresh stirrup
thin stratus
cloud cargo
#

👋 taking over for my colleague. Let me catch up.

thin stratus
#

these are the files I am unable to see remaing time , unused time values

cloud cargo
#

you can calculate those based on the period.start and period.end

thin stratus
#

period.start and end is a time stamp

#

I need to the value of these highlighted section

cloud cargo
#

the info you're asking about is found under lines

thin stratus
#

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

cloud cargo
#

would you mind sharing the request ids where you generated these results

thin stratus
#

req_2vnuMMvGgx2i78

cloud cargo
#

sorry I'm still looking into this

thin stratus
#

no worries

#

I think in the json proration is getting false

cloud cargo
#

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?

thin stratus
#

using this

cloud cargo
#

so that's not the request that you sent me earlier

thin stratus
#

this is the same request I guess

cloud cargo
#

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

thin stratus
#

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

cloud cargo
#

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?

thin stratus
#

var options = new UpcomingInvoiceOptions
{
Customer = customerId,
SubscriptionItems = new List<InvoiceSubscriptionItemOptions>() {
new InvoiceSubscriptionItemOptions(){
Quantity = 6,
Plan = "adfa5454_USD"
}
}
};

cloud cargo
#

you haven't specified a subscription id here

#

so there is no prorations to be calculated

thin stratus
#

okay , let me try this is as well

#

could you please let me know where do I need to pass the subsctionId

cloud cargo
#

in the UpcomingInvoiceOptions

thin stratus
#

in which property

#

I need to pass subscription Id

vivid badger
#

UpcomingInvoiceOptions.Subscription

thin stratus
#

now I am able to get the data but why I am getting amount like "amount": 2391,

#

in what formate the amount is coming

vivid badger
#

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).

thin stratus
#

got it

thin stratus
#

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

vivid badger
#

not understanding you, sorry. Can you clearly state what you expected to see, what you saw instead, and why you expect that?

thin stratus
#

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,
]

vivid badger
#

where did your JSON from exactly? What API calls and code?

thin stratus
#

from this

vivid badger
#

no

#

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.

thin stratus
#

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

vivid badger
#

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.

thin stratus
#

this is the invoice which is going to generate when the user has completed their subscription upddate

#

I need that data

vivid badger
#

sorry but you're not reading what I wrote.

thin stratus
#

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

vivid badger
#

this conversation won't work I'm afraid

thin stratus
#

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

#

this was the endpoint

vivid badger
#

cool

#

what was the exact response?

thin stratus
#

this was the response

vivid badger
#

that's not the exact response, that's a snippet of it.

#

what was the exact full response?

thin stratus
vivid badger
#

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?

thin stratus
#

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

vivid badger
#

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?

thin stratus
#

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

vivid badger
vivid badger
#

we just use the current time and compare it to the time (the billing_cycle_anchor for example) your subscription's periods are for.

thin stratus
#

I am understanding but still have a question

vivid badger
#

what's the question @thin stratus ?

thin stratus
#

is it possible to jump on the call ?

vivid badger
#

it is not

thin stratus
#

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

vivid badger
# thin stratus

can you share the URL of the page where you took this screenshot please?

thin stratus
vivid badger
#

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.

#

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 ?

thin stratus
#

no both are diffrenet methods

#

I have created a separate API for UpcomingInvoice & Subscription.Update.

vivid badger
#

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>

thin stratus
#

both API are separated there in no property called "**proration_date **" event in the docs

#

okay wait

thin stratus
#

I have added proration_date in both the api's now I am checking again

#

here is the log I have passed the proration_date in it

vivid badger
#

cool. Did you have a question?

thin stratus
#

now I am passing all the things correctly but still SubTotal is not matching with invoice screen shot

vivid badger
#

you're not passing them correctly.

#

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.

thin stratus
#

@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

vivid badger
#

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]

thin stratus
#

is is possible to create techincal call setup

vivid badger
#

it is not no

#

you had 7 hours of my team's time, all day today

#

in any case, we don't offer calls.

thin stratus
#

how can we create techinal ticket

vivid badger
#

@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.

vivid badger
#

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.

thin stratus
#

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

vivid badger
#

sorry you feel that way

#

the result is not 0, I completely disagree with you.