#.al2
1 messages · Page 1 of 1 (latest)
👋 happy to help
hello the situation is as I summarized, is there a way to achieve this?
a colleague will be with you shortly
tyvm
Hi! I'm taking over from my colleague. Please, give me a moment to catch up.
"resumes after the last invoices billing cycle end, customer should be charged the full amount" what amount exactly?
For what period?
{
id: 'in_1NVCg4Ha3E1TcO6Kn3j7XdCB',
amount_due: 500,
amount_paid: 0,
status: 'draft',
reason: 'subscription_cycle',
start: 2023-07-18T12:06:46.000Z,
end: 2023-08-18T12:06:46.000Z,
subscription: 'sub_1NVCfzHa3E1TcO6KJeBeWrqB'
},
{
id: 'in_1NVCfzHa3E1TcO6KQQ8UEunC',
amount_due: 500,
amount_paid: 500,
status: 'paid',
reason: 'subscription_create',
start: 2023-07-18T12:06:46.000Z,
end: 2023-07-18T12:06:46.000Z,
subscription: 'sub_1NVCfzHa3E1TcO6KJeBeWrqB'
}
]```
this is before resume
{
id: 'in_1NVCg8Ha3E1TcO6Ku8uiEmBK',
amount_due: 0,
amount_paid: 0,
status: 'paid',
reason: 'subscription_update',
start: 2023-08-19T12:06:51.000Z,
end: 2023-08-19T12:06:51.000Z,
subscription: 'sub_1NVCfzHa3E1TcO6KJeBeWrqB'
},
{
id: 'in_1NVCg4Ha3E1TcO6Kn3j7XdCB',
amount_due: 516,
amount_paid: 516,
status: 'paid',
reason: 'subscription_cycle',
start: 2023-07-18T12:06:46.000Z,
end: 2023-08-18T12:06:46.000Z,
subscription: 'sub_1NVCfzHa3E1TcO6KJeBeWrqB'
},
{
id: 'in_1NVCfzHa3E1TcO6KQQ8UEunC',
amount_due: 500,
amount_paid: 500,
status: 'paid',
reason: 'subscription_create',
start: 2023-07-18T12:06:46.000Z,
end: 2023-07-18T12:06:46.000Z,
subscription: 'sub_1NVCfzHa3E1TcO6KJeBeWrqB'
}
]```
after resuming
after subscription is created I pause the subscription and I'm guessing in_1NVCg4Ha3E1TcO6Kn3j7XdCB is the result of that
I'm using ``` /**
- Pauses a subscription
- @param subscriptionId id of the subscription
- @returns Subscription object
/
public async pauseSubscription(
subscriptionId: string
): Promise<Stripe.Subscription> {
return this.stripe.subscriptions.update(subscriptionId, {
pause_collection: {
behavior: "void",
},
});
}
/* - Resumes a subscription
- @param subscriptionId id of the subscription
- @returns Subscription object
*/
public async unPauseSubscription(
subscriptionId: string
): Promise<Stripe.Subscription> {
return this.stripe.subscriptions.update(subscriptionId, {
billing_cycle_anchor: "now",
pause_collection: "",
});
}``` with "stripe": "^12.0.0",
to pause and unpause
I see you're also resetting the billing_cycle_anchor. What are you exactly trying to achieve?
Do you want to bill the customer for a monthly amount as soon as they resume the subscription?
the ultimate goal is to prevent billing if the resume is within the last paid invoice's period_start and period_end, and if it's greater than period_end of that paid invoice then it needs to charge the full amount on resume
the reason why I reset the billing_cycle_anchor is that I was worried about a case as following: for example billing cycle is on 3rd day of every month but customer resumes at 4th day of next billing cycle month, and doesn't get charged for another month because of resume date was after billing cycle date
What you can do instead is delete the Subscription. You can set the cancel_at_period_end to true when the customer decides to cancel. The Sub will still be active until the paid period is running. If they decide to resume, you can set cancel_at_period_end to false if the sub is not deleted yet, otherwise, create a new Subscription. This will be much easier to maintain. https://stripe.com/docs/api/subscriptions/update#update_subscription-cancel_at_period_end
alright tyvm
Happy to help!