The previous fix hardcoded apple_pay/google_pay as extra filter options, but Payment.method is free-text set by whatever the gateway reports, so guessing at literal values was fragile and still didn't surface them for this user. Add GET /api/payments/mypayments/methods returning the distinct method values actually present in the user's payments, and have the dashboard filter build its options from that instead. Also switch the method filter from a startsWith match to an exact match, since the values now come straight from the same column being filtered. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
const {
|
|
createPayment,
|
|
getPayments,
|
|
getUserPayments,
|
|
getUserPaymentMethods,
|
|
getPaymentById,
|
|
getPaymentsByRegistration,
|
|
getPaymentsByEvent,
|
|
assignDonationToRegistration,
|
|
createYocoCheckout,
|
|
sendPaymentLink,
|
|
createRefund,
|
|
getPaymentStats
|
|
} = require('../controllers/paymentController');
|
|
const { protect, supervisor, staff, admin} = require('../middleware/authMiddleware');
|
|
|
|
// Protected routes
|
|
router.post('/', protect, supervisor, createPayment);
|
|
router.post('/yoco-checkout', protect, createYocoCheckout);
|
|
router.post('/yoco-checkout/send', protect, supervisor, sendPaymentLink);
|
|
router.get('/mypayments', protect, getUserPayments);
|
|
router.get('/mypayments/methods', protect, getUserPaymentMethods);
|
|
router.get('/:id', protect, getPaymentById);
|
|
router.get('/registration/:registrationId', protect, getPaymentsByRegistration);
|
|
|
|
// Admin/Staff routes
|
|
router.get('/', protect, supervisor, getPayments);
|
|
router.get('/event/:eventId', protect, staff, getPaymentsByEvent);
|
|
router.put('/assign-donation', protect, supervisor, assignDonationToRegistration);
|
|
router.post('/refund', protect, supervisor, createRefund);
|
|
router.get('/admin/stats', protect, admin, getPaymentStats);
|
|
|
|
module.exports = router; |