Fix: Add type guards for Stripe subscription current_period_end
All checks were successful
Trigger Cloudarix Deploy / call-webhook (push) Successful in 1s
All checks were successful
Trigger Cloudarix Deploy / call-webhook (push) Successful in 1s
This commit is contained in:
parent
bde9b3fee0
commit
2e41bbc149
@ -41,6 +41,11 @@ export async function POST(request: Request) {
|
||||
const subscription = await stripe.subscriptions.retrieve(
|
||||
session.subscription as string
|
||||
);
|
||||
|
||||
if (!subscription.current_period_end) {
|
||||
return new Response("Invalid subscription data", { status: 400 });
|
||||
}
|
||||
|
||||
const updatedData = {
|
||||
stripeSubscriptionId: subscription.id,
|
||||
stripeCustomerId: subscription.customer as string,
|
||||
@ -82,6 +87,10 @@ export async function POST(request: Request) {
|
||||
session.subscription as string
|
||||
);
|
||||
|
||||
if (!subscription.current_period_end) {
|
||||
return new Response("Invalid subscription data", { status: 400 });
|
||||
}
|
||||
|
||||
// Update the price id and set the new period end.
|
||||
await db
|
||||
.update(subscriptions)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user