#alberto_code

1 messages ยท Page 1 of 1 (latest)

lethal aspenBOT
#

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

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

restive mantleBOT
loud comet
loud comet
# loud comet

Here it can be seen that the user is charged less at the beginning and end of the payment

glacial leaf
#

You would want to look into the concrete value on your request to create Subscription

#

Probably you set the billing_cycle_anchor

loud comet
#

This the product:

glacial leaf
#

and then it prorates on the time differences

loud comet
#

Ok, I'll check

loud comet
#

this is my subscription

glacial leaf
#

Yes but I mean you would want to zoom into the billing cycle

loud comet
#

Could proration be avoided if I remove the billing_cycle_anchor? And make the first charge for the monthly fee separately ๐Ÿค”

glacial leaf
#

Yeah I believe so. You can convert those time into human-readable time to see what you set it to

#

remember all parameters are in UTC

loud comet
#

Alright, but it can't be made visible to people:(

#

This needs to be controlled from the backend

#

jeje

#

The goal is to make recurring payments within a year only, but these payments can be bi-weekly, weekly, or monthly ๐Ÿ˜ƒ

#

So, for this, I need to make 12, 24, or 54 charges during the year with a fixed price. Where:
Monthly = 12
Weekly = 54
Bi-weekly = 24

#

And at the end of the year, the subscription needs to be canceled ๐Ÿ˜…

#

The subscription starts on the day the user purchases a product

#

I'm placing intervals and then multiplying them by the total payment, could that be the error?๐Ÿค”

glacial leaf
#

I think you should use the built in function of Java instead of calculating yourself

#

There could be many more things, like leap year, and or the number of day on each month are different

loud comet
#

I'm using JavaScript as the language, what do you recommend for correctly calculating dates?

glacial leaf
loud comet
#

Actually, that's what I use.

#

In fact, I shared the code with you at the beginning of the thread

#

Do you have a Java implementation of this calculation where the subscription start is the billing_cycle_anchor and the cancellation of the subscription is one year?

glacial leaf
#

Okie let's look at the calculated value of your request

loud comet
#

This is another one I made a few minutes ago, if you'd like, let's consider this one.

glacial leaf
#

I mean, can you find the request id here? req_xxx

loud comet
glacial leaf
#

Billing Cycle Anchor = 2024-05-16 06:00:00 UTC

#

Cancel At = 2025-04-12 02:15:05

#

So the last Invoice of 2025-03-16 to 2025-04-12 will be less than 1 month, so it's 1730.99 instead of 1999.00

loud comet
#

Okay, so it seems like the issue is because I'm setting intervals for the weekly, monthly, and bi-weekly methods. But how can I do this without doing it manually? To achieve a certain number of payments depending on whether it's monthly, bi-weekly, or weekly, all within just one year ๐Ÿค”

glacial leaf
#
const cancelAtDate = new Date(dateNow.getTime() + totalPayments * intervalDays * 24 * 60 * 60 * 1000);

Let's say if totalPayments = 12 (you set monthly), this will calculate on intervalDays = 30?

#

Each month as a different days number, some has 31, some has 30

#

say it's not exactly that 30 days equal to 1 month