feat(billing): implement robust in-app subscription cancellation & fix CI/CD socket port typo
This commit is contained in:
@@ -44,8 +44,19 @@ export async function syncSubscriptionFromStripe(
|
||||
|
||||
const status = mapStripeStatus(subscription.status);
|
||||
|
||||
const currentPeriodStart = new Date(((subscription as any).current_period_start as number) * 1000);
|
||||
const currentPeriodEnd = new Date(((subscription as any).current_period_end as number) * 1000);
|
||||
const currentPeriodStartTimestamp =
|
||||
subscription.current_period_start ??
|
||||
(subscription as any).items?.data?.[0]?.current_period_start ??
|
||||
(subscription as any).start_date ??
|
||||
Math.floor(Date.now() / 1000);
|
||||
|
||||
const currentPeriodEndTimestamp =
|
||||
subscription.current_period_end ??
|
||||
(subscription as any).items?.data?.[0]?.current_period_end ??
|
||||
(currentPeriodStartTimestamp + 30 * 24 * 3600);
|
||||
|
||||
const currentPeriodStart = new Date(currentPeriodStartTimestamp * 1000);
|
||||
const currentPeriodEnd = new Date(currentPeriodEndTimestamp * 1000);
|
||||
|
||||
await prisma.subscription.upsert({
|
||||
where: { stripeSubscriptionId: subscription.id },
|
||||
|
||||
Reference in New Issue
Block a user