From a48d8c317b08cbf42a3120405829c53e9b34ce83 Mon Sep 17 00:00:00 2001
From: DevMirza <53424436+Zaid-maker@users.noreply.github.com>
Date: Sun, 28 Jul 2024 09:30:20 +0000
Subject: [PATCH 6/9] update Checkout
---
components/shared/Checkout.tsx | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/components/shared/Checkout.tsx b/components/shared/Checkout.tsx
index fef453e..b10bcd8 100644
--- a/components/shared/Checkout.tsx
+++ b/components/shared/Checkout.tsx
@@ -1,12 +1,24 @@
+import { checkoutOrder } from "@/lib/actions/order.actions";
import { IEvent } from "@/lib/database/models/event.model";
-import React from "react";
import { Button } from "../ui/button";
const Checkout = ({ event, userId }: { event: IEvent; userId: string }) => {
+ const onCheckout = async () => {
+ const order = {
+ eventTitle: event.title,
+ eventId: event._id,
+ price: event.price,
+ isFree: event.isFree,
+ buyerId: userId,
+ };
+
+ await checkoutOrder(order);
+ };
+
return (
-
);
From d7eb7404ce7b10c3fa862d79173033afb2ccc37b Mon Sep 17 00:00:00 2001
From: DevMirza <53424436+Zaid-maker@users.noreply.github.com>
Date: Sun, 28 Jul 2024 09:37:15 +0000
Subject: [PATCH 7/9] useEffect to check the status of checkout order
---
components/shared/Checkout.tsx | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/components/shared/Checkout.tsx b/components/shared/Checkout.tsx
index b10bcd8..b595211 100644
--- a/components/shared/Checkout.tsx
+++ b/components/shared/Checkout.tsx
@@ -1,8 +1,22 @@
import { checkoutOrder } from "@/lib/actions/order.actions";
import { IEvent } from "@/lib/database/models/event.model";
import { Button } from "../ui/button";
+import { useEffect } from "react";
const Checkout = ({ event, userId }: { event: IEvent; userId: string }) => {
+ useEffect(() => {
+ const query = new URLSearchParams(window.location.search);
+ if (query.get("success")) {
+ console.log("Order placed! You will receive an email confirmation.");
+ }
+
+ if (query.get("canceled")) {
+ console.log(
+ "Order canceled -- continue to shop around and checkout when you’re ready.",
+ );
+ }
+ }, []);
+
const onCheckout = async () => {
const order = {
eventTitle: event.title,
From e1333ce306e04cfe780226e6c19aa71fea66313a Mon Sep 17 00:00:00 2001
From: DevMirza <53424436+Zaid-maker@users.noreply.github.com>
Date: Sun, 28 Jul 2024 11:55:29 +0000
Subject: [PATCH 8/9] loadStripe in Checkout Component
---
components/shared/Checkout.tsx | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/components/shared/Checkout.tsx b/components/shared/Checkout.tsx
index b595211..5348e61 100644
--- a/components/shared/Checkout.tsx
+++ b/components/shared/Checkout.tsx
@@ -1,7 +1,11 @@
-import { checkoutOrder } from "@/lib/actions/order.actions";
+import React, { useEffect } from "react";
+import { loadStripe } from "@stripe/stripe-js";
+
import { IEvent } from "@/lib/database/models/event.model";
import { Button } from "../ui/button";
-import { useEffect } from "react";
+import { checkoutOrder } from "@/lib/actions/order.actions";
+
+loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY!);
const Checkout = ({ event, userId }: { event: IEvent; userId: string }) => {
useEffect(() => {
From 3a94f647cfcb4a159c1ab750769d1b2a5db06e1b Mon Sep 17 00:00:00 2001
From: DevMirza <53424436+Zaid-maker@users.noreply.github.com>
Date: Sun, 28 Jul 2024 16:43:09 +0000
Subject: [PATCH 9/9] reminder
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index d606cc0..c854edf 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,5 @@
#
Build an event organization web app like Eventbrite or Meetup with authentication, event management, search, filtering, categories, checkout, and payments using Next JS 14, Tailwind CSS, Shadcn, React Hook Form, Zod, Uploadthing, React-Datepicker, Mongoose, Clerk, and Stripe.
+
+`ngrok tunnel --label edge=edghts_2jQbAk4QzC90ArEGm4eYkVIhI1v http://localhost:3000`