create new route for order page
This commit is contained in:
parent
bb4d1adf73
commit
c1c840bf7e
6 changed files with 16 additions and 7 deletions
|
@ -53,7 +53,7 @@ export async function POST(req){
|
||||||
|
|
||||||
|
|
||||||
const stripeSession = await stripe.checkout.sessions.create({
|
const stripeSession = await stripe.checkout.sessions.create({
|
||||||
line_items: stripeLineItems,
|
line_items: stripeLineItems,
|
||||||
mode: 'payment',
|
mode: 'payment',
|
||||||
customer_email: userEmail,
|
customer_email: userEmail,
|
||||||
success_url: process.env.NEXTAUTH_URL + 'orders/' + orderDoc._id.toString() + '?clear-cart=1',
|
success_url: process.env.NEXTAUTH_URL + 'orders/' + orderDoc._id.toString() + '?clear-cart=1',
|
||||||
|
|
|
@ -27,7 +27,7 @@ const OrderSchema = new Schema({
|
||||||
},
|
},
|
||||||
paid: {
|
paid: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false
|
||||||
},
|
},
|
||||||
|
|
||||||
}, {timestamps: true})
|
}, {timestamps: true})
|
||||||
|
|
9
donutshop_ecommerce/src/app/api/orders/route.js
Normal file
9
donutshop_ecommerce/src/app/api/orders/route.js
Normal 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);
|
||||||
|
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ export async function POST(req){
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const reqBuffer = await req.text();
|
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);
|
event = stripe.webhooks.constructEvent(reqBuffer, sig, signSecret);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return Response.json(error, {status: 400});
|
return Response.json(error, {status: 400});
|
||||||
|
|
|
@ -14,7 +14,6 @@ const CartPage = () => {
|
||||||
const {data:profileCheckoutData} = useProfile()
|
const {data:profileCheckoutData} = useProfile()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(typeof window !== 'undefined'){
|
if(typeof window !== 'undefined'){
|
||||||
if(window.location.href.includes('canceled=1')){
|
if(window.location.href.includes('canceled=1')){
|
||||||
|
|
|
@ -17,13 +17,14 @@ const OrdersPage = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='pb-20 md:pb-40'>
|
<div className='pb-20 md:pb-40'>
|
||||||
<div className='px-5 md:px-10 py-5 sm:py-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'>
|
<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-10'/>
|
<Image src='/check.png' width={100} height={100} alt='checked' className='mb-6'/>
|
||||||
<p className='uppercase'>Thank you</p>
|
<p className='uppercase'>Thank you</p>
|
||||||
<p className='uppercase text-xl'>Your order is confirmed</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>
|
<p className='text-sm'>We will be sending you an email confirmation to your email shortly</p>
|
||||||
</div>
|
</div>
|
||||||
|
product
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue