michaelshimeles / nextjs-starter-kit

The Ulimate Nextjs Starter Kit. Build your next SAAS product of your dreams. Batteries included.
https://starter.rasmic.xyz/
MIT License
1.2k stars 292 forks source link

Im receiving this after success payment, on success page #16

Open w1redl4in opened 1 month ago

w1redl4in commented 1 month ago

Error: Stripe: Argument "session" must be a string, but got: undefined (on API request to GET /v1/checkout/sessions/{session})

Success page is just like the template

import { Button } from "@/components/ui/button";
import NavBar from "@/components/wrapper/navbar";
import Link from "next/link";
import Stripe from "stripe";

// Initialize Stripe with your secret key
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);

export default async function SuccessPage(props: {
  searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
}) {
  const searchParams = await props.searchParams;

  const session = await stripe.checkout.sessions.retrieve(
    searchParams?.session_id as string
  );

  const jsonString = JSON.stringify(session, null, 2);

  return (
    <main className="flex min-w-screen flex-col items-center justify-between">
      <NavBar />
      <h1 className="mt-[35vh] mb-3 scroll-m-20  text-5xl font-semibold tracking-tight transition-colors first:mt-0">
        Welcome to Nextjs Starter Kit 🎉
      </h1>
      <p className="leading-7 text-center w-[60%]">Let&apos;s get cooking</p>
      <Link href="/dashboard" className="mt-4">
        <Button>Access Dashboard</Button>
      </Link>
    </main>
  );
}