- src/payments: provider registry and PaymentProvider interface (createCheckout, verifyWebhook/parseWebhook, getTransaction, refund, listTransactions as capabilities), Yoco as the first provider. All four direct Yoco checkout calls go through payments.createCheckout. - Webhook split into the provider part (signature, parsing) and shared processing; same URL (/api/webhooks/yoco), same behaviour. - YocoTransaction renamed in place to ProviderTransaction (+ provider, unique per provider + externalId); Payment.provider added and backfilled to "yoco". Payment.method stays the wallet type so cashups are unchanged. - Site settings → Payments: Enabled toggle and order per provider; Yoco's settings shown while it's enabled. R15 minimum for all online payments. - New endpoint names (/api/payments/checkout, /api/provider-transactions); the old /yoco-checkout and /yoco-transactions paths still work. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
539 B
JavaScript
21 lines
539 B
JavaScript
const { handleProviderWebhook } = require('../payments/webhook');
|
|
|
|
// @desc Handle Yoco webhook events (signature check and processing: src/payments)
|
|
// @route POST /api/webhooks/yoco
|
|
// @access Public
|
|
const handleYocoWebhook = handleProviderWebhook('yoco');
|
|
|
|
const handleWhatsappWebhook = async (req, res) => {
|
|
try {
|
|
const { body } = req;
|
|
const { message } = body;
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Internal Server Error' });
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
handleYocoWebhook,
|
|
handleWhatsappWebhook,
|
|
};
|