+
+
Shopping Cart
+
1 item
+
+
+
+
+
+
+
Job Posting
+
+ 6 Months, Cross-posting enabled
+
-
-
- {/*
-
$10
+
$10
-
-
Subtotal
-
- {loading ? 'Loading...' : `$${jobPostings.length * 10}`}
-
+
+
+
Subtotal
+
+ {loading ? 'Loading...' : `$${jobPostings.length * 10}`}
-
- {/*
+
+
+ {/*
Proceed to Checkout
*/}
-
-
+
-
-
+
+
+
+ );
+}
+
+export default function PreviewPage() {
+ return (
+
+
);
}
From 125d0c45c88712a4c6f5150d5bb7aea5ce48325a Mon Sep 17 00:00:00 2001
From: shye <113232835+justshye@users.noreply.github.com>
Date: Tue, 28 May 2024 13:03:40 -0700
Subject: [PATCH 19/21] Update paid status of listing after payment
---
src/app/payment/page.js | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/src/app/payment/page.js b/src/app/payment/page.js
index e054d0d..e281f36 100644
--- a/src/app/payment/page.js
+++ b/src/app/payment/page.js
@@ -60,6 +60,39 @@ function Cart() {
const res = await response.json();
const unpaidPostings = res.jobPostings.filter(posting => !posting.paid);
setJobPostings(unpaidPostings);
+
+ if (paymentStatus === 'true') {
+ const promises = unpaidPostings.map(async posting => {
+ const validThrough = new Date();
+ validThrough.setMonth(validThrough.getMonth() + 6);
+
+ const patchData = {
+ paid: true,
+ validThrough: validThrough.toISOString(),
+ };
+
+ const patchResponse = await fetch(
+ `/api/job-posting?job-posting-id=${posting._id}`,
+ {
+ method: 'PATCH',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(patchData),
+ }
+ );
+
+ if (patchResponse.ok) {
+ console.log(`Job posting ${posting._id} updated successfully`);
+ } else {
+ console.error(
+ `Failed to update job posting ${posting._id}:`,
+ patchResponse.statusText
+ );
+ }
+ });
+ await Promise.all(promises);
+ }
} else {
console.error('Failed to fetch job postings:', response.statusText);
}
From 4dd4c0abb204cf0bfbbb503f9af2d400dc4dd79d Mon Sep 17 00:00:00 2001
From: shye <113232835+justshye@users.noreply.github.com>
Date: Tue, 28 May 2024 13:47:49 -0700
Subject: [PATCH 20/21] Redirect to payment successful after paying
---
src/app/payment/page.js | 51 +++++++++++++++++++++++++++++++++++++----
1 file changed, 46 insertions(+), 5 deletions(-)
diff --git a/src/app/payment/page.js b/src/app/payment/page.js
index e281f36..83a2941 100644
--- a/src/app/payment/page.js
+++ b/src/app/payment/page.js
@@ -8,6 +8,7 @@ import Footer from '@/components/ui/footer';
import { useCallback } from 'react';
import { useEffect } from 'react';
import { Suspense } from 'react';
+import Link from 'next/link';
// Make sure to call `loadStripe` outside of a component’s render to avoid
// recreating the `Stripe` object on every render.
@@ -116,12 +117,52 @@ function Cart() {
const searchParams = useSearchParams();
const paymentStatus = searchParams.get('paymentStatus');
- if (paymentStatus) {
+ function CircleCheckIcon(props) {
return (
- <>
-
Payment Status
-
Payment was successful: {paymentStatus}
- >
+
+ );
+ }
+
+ if (paymentStatus && paymentStatus === 'true') {
+ const links = [
+ { text: 'Home', url: '/admin-panel/home' },
+ { text: 'About', url: '/wip' },
+ { text: 'Logout', url: '/api/auth/logout' },
+ ];
+ return (
+
+
+
+
+
+
+
Payment Successful
+
+ Your payment was processed successfully.
+
+
+
+ Return to Home
+
+
+
+
+
);
}
From d5407ecd8567eb33252d1e96ab6d9318fc9446dc Mon Sep 17 00:00:00 2001
From: shye <113232835+justshye@users.noreply.github.com>
Date: Tue, 28 May 2024 13:49:26 -0700
Subject: [PATCH 21/21] Add comment to warn about vulnerability
---
src/app/api/stripe/route.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/app/api/stripe/route.js b/src/app/api/stripe/route.js
index dd22811..1153280 100644
--- a/src/app/api/stripe/route.js
+++ b/src/app/api/stripe/route.js
@@ -20,7 +20,7 @@ export async function POST(req) {
},
],
mode: 'payment',
- success_url: `${baseURL}/?paymentStatus=true`,
+ success_url: `${baseURL}/?paymentStatus=true`, // This needs to be changed because right now you can just change the URL to get your postings marked as active
cancel_url: `${baseURL}/?paymentStatus=false`,
});