#rohith_code

1 messages ยท Page 1 of 1 (latest)

cerulean zincBOT
#

๐Ÿ‘‹ 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/1374009534787354625

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

boreal arrow
#

Hi there ๐Ÿ‘‹

I don't see a question in your post, so I'm not really sure what you're asking for help/clarity about.

When updating a Subscription, you can provide a proration_date parameter to specify what timestamp should be used for proration calculations:
https://docs.stripe.com/api/subscriptions/update?#update_subscription-proration_date

If you're first showing your customers what they would pay to upgrade, I'd suggest using a single proration_date for both calculating the prorations to show them as well as in the actual Subscription update request.

but this has a catch if user subscribes at 10 am and chose to upgrade at 11 am , proration date is set as 00 so its throwing error as date should between start date and end date
I'm not sure I'm grasping what is being described here. Doesn't this code return a timestamp, how are you seeing that ending up with a value of 0?

quartz spire
#

hello

#

assume start time of subscription cycle is
1747739912 which is
Tuesday, May 20, 2025 11:18:32 AM
and end of cycle is June 20, 2025 4:48:32 PM
if user chooses to upgrade immediately on day of subscription May 20, 2025 2:48:32 PM
if i use proration_date as DateTime.UtcNow.Date
which will be May 20, 2025 00:00:00 AM

#

so this is throwing error as proration date is out of cycle

boreal arrow
#

Oh, you're rounding to the nearest day? Yeah, that's going to lead to problems

quartz spire
#

if i donot use prorationdate , it is using time with seconds

#

which is showing different values by the time user click okay and i upgrade

boreal arrow
#

proration_date accepts a second-precise unix timestamp. If you don't explicitly provide a value for it, then we use the current system time for calculating prorations.

quartz spire
#

yes but that is creating problem for me
i want to show only hour based

#

because im showing a price using invoice preview and by the user accepts that and i perform actual upgrade price is changed

boreal arrow
#

Apologies if it wasn't clear before, but I suggest you use proration_date for both the preview request and the Subscription update request, and that you set that to the timestamp you want to use for calculating prorations. That way the preview creation request and Subscription update request use the same timestamp for calculating prorations.

This is the same approach we suggest here in our guide for handling prorations:
https://docs.stripe.com/billing/subscriptions/prorations#preview-proration

quartz spire
#

i'm using it for both still i have this issue of time

boreal arrow
#

What is the issue you have? Do you have request IDs that you can share from requests you made to test this behavior? Or object IDs from your testing?

quartz spire
#

sir as i mentioned
if dont use proration date , in both preview nad upgrade amunt is different as it is caluclated in sec

#

and if i use proration date with only date in that case i am running into below issue

#

assume start time of subscription cycle is
1747739912 which is
Tuesday, May 20, 2025 11:18:32 AM
and end of cycle is June 20, 2025 4:48:32 PM
if user chooses to upgrade immediately on day of subscription May 20, 2025 2:48:32 PM
if i use proration_date as DateTime.UtcNow.Date
which will be May 20, 2025 00:00:00 AM
so this is throwing error as proration date is out of cycle