create new route for order page

This commit is contained in:
Juthatip McDevitt 2024-05-25 19:54:54 -05:00
parent bb4d1adf73
commit c1c840bf7e
6 changed files with 16 additions and 7 deletions

View file

@ -53,7 +53,7 @@ export async function POST(req){
const stripeSession = await stripe.checkout.sessions.create({
line_items: stripeLineItems,
line_items: stripeLineItems,
mode: 'payment',
customer_email: userEmail,
success_url: process.env.NEXTAUTH_URL + 'orders/' + orderDoc._id.toString() + '?clear-cart=1',

View file

@ -27,7 +27,7 @@ const OrderSchema = new Schema({
},
paid: {
type: Boolean,
default: false,
default: false
},
}, {timestamps: true})

View file

@ -0,0 +1,9 @@
import mongoose from "mongoose";
import { getServerSession } from "next-auth"
import { authOptions } from "../auth/[...nextauth]/route"
export async function GET(){
mongoose.connect(process.env.MONGO_URL);
const session = await getServerSession(authOptions);
}

View file

@ -7,7 +7,7 @@ export async function POST(req){
try {
const reqBuffer = await req.text();
const signSecret = process.env.STRIPE_SIGN_SECRET
const signSecret = process.env.STRIPE_SIGN_SECRET;
event = stripe.webhooks.constructEvent(reqBuffer, sig, signSecret);
} catch (error) {
return Response.json(error, {status: 400});

View file

@ -14,7 +14,6 @@ const CartPage = () => {
const {data:profileCheckoutData} = useProfile()
useEffect(() => {
if(typeof window !== 'undefined'){
if(window.location.href.includes('canceled=1')){

View file

@ -17,13 +17,14 @@ const OrdersPage = () => {
return (
<div className='pb-20 md:pb-40'>
<div className='px-5 md:px-10 py-5 sm:py-10'>
<div className='flex flex-col gap-4 items-center justify-center text-center'>
<Image src='/check.png' width={100} height={100} alt='checked' className='mb-10'/>
<div className='px-5 md:px-10 py-5 sm:py-10 max-w-2xl mx-auto'>
<div className='flex flex-col gap-4 items-center justify-center text-center mb-10'>
<Image src='/check.png' width={100} height={100} alt='checked' className='mb-6'/>
<p className='uppercase'>Thank you</p>
<p className='uppercase text-xl'>Your order is confirmed</p>
<p className='text-sm'>We will be sending you an email confirmation to your email shortly</p>
</div>
product
</div>
</div>
)