Fix: Cast Stripe subscription to correct type
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
2e41bbc149
commit
09f0ea8aa7
@ -40,11 +40,7 @@ export async function POST(request: Request) {
|
|||||||
if (event.type === "checkout.session.completed") {
|
if (event.type === "checkout.session.completed") {
|
||||||
const subscription = await stripe.subscriptions.retrieve(
|
const subscription = await stripe.subscriptions.retrieve(
|
||||||
session.subscription as string
|
session.subscription as string
|
||||||
);
|
) as Stripe.Subscription;
|
||||||
|
|
||||||
if (!subscription.current_period_end) {
|
|
||||||
return new Response("Invalid subscription data", { status: 400 });
|
|
||||||
}
|
|
||||||
|
|
||||||
const updatedData = {
|
const updatedData = {
|
||||||
stripeSubscriptionId: subscription.id,
|
stripeSubscriptionId: subscription.id,
|
||||||
@ -85,11 +81,7 @@ export async function POST(request: Request) {
|
|||||||
// Retrieve the subscription details from Stripe.
|
// Retrieve the subscription details from Stripe.
|
||||||
const subscription = await stripe.subscriptions.retrieve(
|
const subscription = await stripe.subscriptions.retrieve(
|
||||||
session.subscription as string
|
session.subscription as string
|
||||||
);
|
) as Stripe.Subscription;
|
||||||
|
|
||||||
if (!subscription.current_period_end) {
|
|
||||||
return new Response("Invalid subscription data", { status: 400 });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the price id and set the new period end.
|
// Update the price id and set the new period end.
|
||||||
await db
|
await db
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user