Add prepaid resource credits with prorated deploy billing.
When users delete an app before plan expiry, remaining resources become credits for a new deploy. The deploy calculator shows covered vs additional charges, prices optional services correctly, and prorates extras to days left on the credit. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -54,12 +54,19 @@ export class AppLifecycleService implements OnModuleInit, OnModuleDestroy {
|
||||
* Activate or reactivate an application after successful payment.
|
||||
* Calculates the new expiry based on billing cycle and scales pods back up.
|
||||
*/
|
||||
async activateApp(appId: string, billingCycle: BillingCycle, planId: string): Promise<Application> {
|
||||
async activateApp(
|
||||
appId: string,
|
||||
billingCycle: BillingCycle,
|
||||
planId: string,
|
||||
planExpiresAt?: Date,
|
||||
): Promise<Application> {
|
||||
const app = await this.appRepo.findOne({ where: { id: appId } });
|
||||
if (!app) throw new Error(`Application ${appId} not found`);
|
||||
|
||||
const now = new Date();
|
||||
const expiresAt = this.calculateExpiry(now, billingCycle);
|
||||
const expiresAt = planExpiresAt && planExpiresAt > now
|
||||
? planExpiresAt
|
||||
: this.calculateExpiry(now, billingCycle);
|
||||
|
||||
app.planId = planId;
|
||||
app.billingCycle = billingCycle;
|
||||
|
||||
Reference in New Issue
Block a user