diff --git a/backend/api/views/donation_handler.py b/backend/api/views/donation_handler.py index 87b8069..9926daa 100644 --- a/backend/api/views/donation_handler.py +++ b/backend/api/views/donation_handler.py @@ -26,8 +26,8 @@ def donation_handler(request): } ], mode="payment", - success_url="https://google.com", # this should route to the /success page - cancel_url="https://google.com", # this should route back to the donate page + success_url="http://localhost:3000/success?session_id={CHECKOUT_SESSION_ID}", # this should route to the /success page + cancel_url="http://localhost:3000/donate", # this should route back to the donate page ) return Response({"url": checkout_session.url}, status=status.HTTP_200_OK) except Exception as e: diff --git a/webapp/src/pages/about-us.tsx b/webapp/src/pages/about-us.tsx index 7b5ddbe..18b3bf8 100644 --- a/webapp/src/pages/about-us.tsx +++ b/webapp/src/pages/about-us.tsx @@ -22,7 +22,6 @@ const AboutUs = (): JSX.Element => { fetch("http://127.0.0.1:8000/api/portfolio/") .then((response) => response.json()) .then((data) => { - console.log("API Data:", data); setPortfolio(data.portfolio || []); setTotalInvestment(data.total_investment || 0); }) diff --git a/webapp/src/pages/donate.tsx b/webapp/src/pages/donate.tsx index 80131ab..3373ac3 100644 --- a/webapp/src/pages/donate.tsx +++ b/webapp/src/pages/donate.tsx @@ -1,5 +1,6 @@ import { FC, useState, useEffect } from 'react'; import axios from 'axios'; +import { useCookies } from 'react-cookie'; import { fetchDonations, fetchDonationAmount } from '@/util/charity'; interface DonationData { @@ -17,6 +18,7 @@ interface CharityData { const DonatePage: FC = () => { const [loading, setLoading] = useState(false); const [donationData, setDonationData] = useState(null); + const [cookies] = useCookies(['token']); const [charities, setCharities] = useState([]); useEffect(() => { @@ -34,15 +36,17 @@ const DonatePage: FC = () => { const handleDonate = async (fixed: string, amount: string) => { setLoading(true); try { - const response = await axios.post( - 'http://localhost:8000/api/donation', - { fixed, amount }, - { - headers: { 'Content-Type': 'application/json' }, - responseType: 'text', - validateStatus: () => true, - } - ); + const response = await axios.post('http://localhost:8000/api/donation', { + fixed, + amount + }, { + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${cookies.token}` + }, + responseType: 'text', + validateStatus: () => true + }); const data = JSON.parse(response.data); if (data.url) { diff --git a/webapp/src/pages/home.tsx b/webapp/src/pages/home.tsx index 5a53bef..a1b8059 100644 --- a/webapp/src/pages/home.tsx +++ b/webapp/src/pages/home.tsx @@ -40,7 +40,6 @@ export default function HomePage() { const donationsResponse = await getTotalDonations(); const donations = donationsResponse?.data?.donation_total || -1; // Safely access donation_total and alert that something is wrong by using -1 setDonationStockData({ amount: donations }); - console.log(donationsResponse.data); }; fetchData(); }, []); diff --git a/webapp/src/pages/register.tsx b/webapp/src/pages/register.tsx index 16e1c9e..e920065 100644 --- a/webapp/src/pages/register.tsx +++ b/webapp/src/pages/register.tsx @@ -63,7 +63,6 @@ const RegisterPage: () => JSX.Element = () => { }, []); const handlePhoneChange = (value: string) => { - console.log("PhoneInput Raw Value:", value); const formattedValue = value.startsWith("+") ? value : `+${value}`; setPhoneNumber(formattedValue); setValue("phone_number", formattedValue); diff --git a/webapp/src/pages/success.tsx b/webapp/src/pages/success.tsx index 728c547..99c74aa 100644 --- a/webapp/src/pages/success.tsx +++ b/webapp/src/pages/success.tsx @@ -38,7 +38,7 @@ const SuccessPage: FC = () => { const charity = "Lorem Ipsum"; // making request to backend - await axios.post('http://localhost:8000/api/send-payment-recieved-email/', { receiver: email, charity }); + await axios.post('http://localhost:8000/api/send-payment-recieved-email', { receiver: email, charity }); } catch (error) { console.error("Error sending payment received email:", error); // TODO: Still need to add the donation record to the DB somehow