#sanjay_api
1 messages · Page 1 of 1 (latest)
đź‘‹ 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/1389846638826098739
📝 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.
- sanjay_api, 4 days ago, 6 messages
Hi! Looking into your query.
This is what I tried:
async createSubscription(customerId, priceId1, priceId2, startDateUnix) {
const sub = await this.stripe.subscriptions.create({
customer: customerId,
items: [
{price: priceId1, quantity: 1},
{price: priceId2}
],
backdate_start_date: startDateUnix,
expand: ["latest_invoice.payment_intent"]
});
return sub;
}
Thank you for waiting! Looking at your request to create the subscription (https://dashboard.stripe.com/test/logs/req_dv1Zk55HwQp3qp), you passed 1751394600 as the backdate_start_date which is 2025-07-01 18:30:00 UTC. And you created the subscription on 2025-07-02 04:41:06 UTC. This automatically created a proration for price_1RfgVsCpfpVCWu67RrChlEQB between the 2 date / timings. And then it also charged the full amount of 150 from the billing cycle anchor to the next end period which is a day.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
inorder to avoid the extra 63 usd (proration) and only charge 150 usd, what should i do?
Any reason you are passing backdate_start_date?
so that i will get every monthly invoices on corresponding day next month at 12 am only (00:00:00 time)
backdate_start_date is a past timestamp to backdate the subscription’s start date to. So when you set this, your first invoice will contain line items for the time between the start date and the current time when you created the Subscription.
https://docs.stripe.com/api/subscriptions/create#create_subscription-backdate_start_date
I think you want to set the billing cycle anchor instead: https://docs.stripe.com/billing/subscriptions/billing-cycle?
i tried with proration: none, it worked.
But still, the next invoice time is not 12 am (next month), even if i backdated to 12 am today while creating subscription
Back date just determines when the subscription started. Then the amount is prorated to be charged from the backdated date to the time the subscription is created.
Can you take a look at the billing cycle anchor instead and see if this is what you want? https://docs.stripe.com/billing/subscriptions/billing-cycle
my requirement is that i need to charge the flat rate immediately when subscription is created, after that next month (same date) at 12 am (00:00:00), i need to charge the usage of this billing period along with the flat charge of next month
if i use billing anchor, it charges the flat charge at that particular time right?
Lets say you were to create a subscription on 2nd July 17:00:00 UTC, you want $150 charged for 2nd July and then you want subsequent charges to be 3rd July 00:00:00, 4th July 00:00:00, 5th July 00:00:00, etc.?
yes, something like this (but monthly, yeah i will update the billing period of those prices to monthly)
In that case you should set the billing cycle anchor instead: https://docs.stripe.com/billing/subscriptions/billing-cycle
you mean to create first subscription with only flat price and then create a new subscription item for usage based price (tiered) with billing anchor to next month
You can set the billing cycle anchor when you create the subscription with both the prices.
but then it wont charge immeediately right?
It depends on how you set the proration: https://docs.stripe.com/billing/subscriptions/billing-cycle#configure-proration-behavior
as per my requirements, when should i set bililing anchor?
If you create a subscription today, but want it to bill at the start of each month, you can set the date for the billing cycle anchor as 1 August.
async createSubscription(customerId, priceId1, priceId2, threshold, startDateUnix) {
const nextMonth12AM = new Date();
nextMonth12AM.setMonth(nextMonth12AM.getMonth() + 1);
nextMonth12AM.setDate(nextMonth12AM.getDate());
nextMonth12AM.setHours(0, 0, 0, 0);
const sub = await this.stripe.subscriptions.create({
customer: customerId,
items: [
{price: priceId1, quantity: 1},
{price: priceId2}
],
billing_thresholds: {
amount_gte: threshold,
reset_billing_cycle_anchor: false
},
backdate_start_date: startDateUnix,
billing_cycle_anchor: Math.floor(nextMonth12AM.getTime() / 1000),
proration_behavior: "always_invoice",
expand: ["latest_invoice.payment_intent"]
});
return sub;
}
you mean this right?
i think i found the solution
I still see that you are passing the backdate_start_date. This will result in the same issue as you had earlier.