- src/payments/status.js: open checkouts, checkCheckouts and the payment-status job (every 15 min, checkouts 10 min - 3 days old). Found payments are settled exactly as their webhook would be (settlePayment, extracted from the webhook handler: amount check, record, emails). - PayFast: signed API client (alphabetical signature, testing=true in sandbox), findPayments from the transaction history CSV matched on M Payment ID, and testConnection (signed /ping). Verified against a real sandbox account. - Yoco documents no checkout lookup, so its checkouts are "can't check". - Payments -> Reconcile: "Waiting for payment" with Check status / Check all; PayFast card: Test connection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
2.1 KiB
JavaScript
48 lines
2.1 KiB
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
const {
|
|
createPayment,
|
|
getPayments,
|
|
getUserPayments,
|
|
getPaymentById,
|
|
getPaymentsByRegistration,
|
|
getPaymentsByEvent,
|
|
assignDonationToRegistration,
|
|
unassignDonationFromRegistration,
|
|
createCheckout,
|
|
sendPaymentLink,
|
|
createRefund,
|
|
getPaymentStats,
|
|
sendReceipt,
|
|
} = require('../controllers/paymentController');
|
|
const { listPaymentProviders, getPaymentProviderSettings, updatePaymentProviderSettings, getPayPage, choosePayProvider, listOpenCheckouts, checkCheckoutStatus } = require('../controllers/paymentProvidersController');
|
|
const { protect, supervisor, staff, admin} = require('../middleware/authMiddleware');
|
|
|
|
// Protected routes
|
|
router.post('/', protect, supervisor, createPayment);
|
|
router.get('/providers', listPaymentProviders);
|
|
router.get('/pay/:id', getPayPage);
|
|
router.post('/pay/:id', choosePayProvider);
|
|
router.get('/checkouts/open', protect, supervisor, listOpenCheckouts);
|
|
router.post('/checkouts/check', protect, supervisor, checkCheckoutStatus);
|
|
router.get('/providers/settings', protect, admin, getPaymentProviderSettings);
|
|
router.put('/providers/settings', protect, admin, updatePaymentProviderSettings);
|
|
router.post('/checkout', protect, createCheckout);
|
|
router.post('/checkout/send', protect, supervisor, sendPaymentLink);
|
|
// Older names, kept for existing clients
|
|
router.post('/yoco-checkout', protect, createCheckout);
|
|
router.post('/yoco-checkout/send', protect, supervisor, sendPaymentLink);
|
|
router.get('/mypayments', protect, getUserPayments);
|
|
router.post('/:id/send-receipt', protect, sendReceipt);
|
|
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('/unassign-donation', protect, supervisor, unassignDonationFromRegistration);
|
|
router.post('/refund', protect, supervisor, createRefund);
|
|
router.get('/admin/stats', protect, admin, getPaymentStats);
|
|
|
|
module.exports = router; |