Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/api/views/donation_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion webapp/src/pages/donate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FC, useState, useEffect } from 'react';
import axios from 'axios';
import {fetchDonations, fetchInfo} from '@/util/charity';
import ImageWithDescription from '@/components/charity-card';
import { useCookies } from 'react-cookie';

interface DonationData {
amount: number;
Expand All @@ -17,6 +18,7 @@ const DonatePage: FC = () => {
const [loading, setLoading] = useState<boolean>(false);
const [donationData, setDonationData] = useState<DonationData | null>(null);
const [charityData, setCharityData] = useState<CharityData | null>(null);
const [cookies] = useCookies(['token']);

useEffect(() => {

Expand All @@ -39,7 +41,8 @@ const DonatePage: FC = () => {
amount
}, {
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
'Authorization': `Bearer ${cookies.token}`
},
responseType: 'text',
validateStatus: () => true
Expand Down
1 change: 0 additions & 1 deletion webapp/src/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}, []);
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/pages/success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down