fix build

This commit is contained in:
KMKoushik
2025-05-02 21:58:38 +10:00
parent d6e0126f7b
commit 2de7147cdf
7 changed files with 56 additions and 44 deletions

View File

@@ -125,13 +125,21 @@ export async function syncStripeData(customerId: string) {
return;
}
if (!subscription.items.data[0]) {
return;
}
await db.subscription.upsert({
where: { id: subscription.id },
update: {
status: subscription.status,
priceId: subscription.items.data[0]?.price?.id || "",
currentPeriodEnd: new Date(subscription.current_period_end * 1000),
currentPeriodStart: new Date(subscription.current_period_start * 1000),
currentPeriodEnd: new Date(
subscription.items.data[0]?.current_period_end * 1000
),
currentPeriodStart: new Date(
subscription.items.data[0]?.current_period_start * 1000
),
cancelAtPeriodEnd: subscription.cancel_at
? new Date(subscription.cancel_at * 1000)
: null,
@@ -142,8 +150,12 @@ export async function syncStripeData(customerId: string) {
id: subscription.id,
status: subscription.status,
priceId: subscription.items.data[0]?.price?.id || "",
currentPeriodEnd: new Date(subscription.current_period_end * 1000),
currentPeriodStart: new Date(subscription.current_period_start * 1000),
currentPeriodEnd: new Date(
subscription.items.data[0]?.current_period_end * 1000
),
currentPeriodStart: new Date(
subscription.items.data[0]?.current_period_start * 1000
),
cancelAtPeriodEnd: subscription.cancel_at
? new Date(subscription.cancel_at * 1000)
: null,

View File

@@ -6,7 +6,7 @@ const METER_EVENT_NAME = "unsend_usage";
export async function sendUsageToStripe(customerId: string, usage: number) {
const stripe = new Stripe(env.STRIPE_SECRET_KEY!, {
apiVersion: "2025-01-27.acacia",
apiVersion: "2025-03-31.basil",
});
const meterEvent = await stripe.billing.meterEvents.create({