Formated Files

This commit is contained in:
Ahmad 2024-02-15 20:49:19 -05:00
parent d5631b309a
commit e768d9181f
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
138 changed files with 1829 additions and 1851 deletions

View file

@ -1,13 +1,13 @@
import Stripe from "stripe";
import { headers } from "next/headers";
import { NextResponse } from "next/server";
import Stripe from 'stripe';
import { headers } from 'next/headers';
import { NextResponse } from 'next/server';
import { db } from "@/lib/db";
import { stripe } from "@/lib/stripe";
import { db } from '@/lib/db';
import { stripe } from '@/lib/stripe';
export async function POST(req: Request) {
const body = await req.text();
const signature = headers().get("Stripe-Signature") as string;
const signature = headers().get('Stripe-Signature') as string;
let event: Stripe.Event;
@ -23,13 +23,13 @@ export async function POST(req: Request) {
const session = event.data.object as Stripe.Checkout.Session;
if (event.type === "checkout.session.completed") {
if (event.type === 'checkout.session.completed') {
const subscription = await stripe.subscriptions.retrieve(
session.subscription as string
);
if (!session?.metadata?.orgId) {
return new NextResponse(JSON.stringify({ error: "Missing orgId" }), {
return new NextResponse(JSON.stringify({ error: 'Missing orgId' }), {
status: 400,
});
}
@ -47,7 +47,7 @@ export async function POST(req: Request) {
});
}
if (event.type === "invoice.payment_succeeded") {
if (event.type === 'invoice.payment_succeeded') {
const subscription = await stripe.subscriptions.retrieve(
session.subscription as string
);