diff --git a/client/play/geoword/admin/manage-payments.js b/client/play/geoword/admin/manage-payments.js index 2983eac57..97642fe6b 100644 --- a/client/play/geoword/admin/manage-payments.js +++ b/client/play/geoword/admin/manage-payments.js @@ -41,6 +41,7 @@ document.getElementById('record-payment-form').addEventListener('submit', event switch (response.status) { case 200: return window.location.reload(); case 400: return window.alert('User not found'); + case 404: return window.alert('Packet not found'); default: return window.alert('Something went wrong. Please try again.'); } }); diff --git a/routes/api/geoword/admin/record-payment.js b/routes/api/geoword/admin/record-payment.js index ada74dd61..dd6ca3b7a 100644 --- a/routes/api/geoword/admin/record-payment.js +++ b/routes/api/geoword/admin/record-payment.js @@ -1,6 +1,7 @@ import getCost from '../../../../database/geoword/get-cost.js'; import recordPayment from '../../../../database/geoword/record-payment.js'; import getUserId from '../../../../database/account-info/get-user-id.js'; +import getPacketStatus from '../../../../database/geoword/get-packet-status.js'; import { Router } from 'express'; @@ -9,6 +10,8 @@ const router = Router(); router.put('/', async (req, res) => { const { packetName, username } = req.body; + if (await getPacketStatus(packetName) === null) { return res.status(404).send('Packet not found'); } + const userId = await getUserId(username); if (!userId) { return res.status(400).send('User not found'); }