feat: integrate Stripe payment module with API + UI components

This commit is contained in:
2026-06-09 21:10:57 +05:30
parent 944a745892
commit 5eb06b2809
25 changed files with 1434 additions and 1 deletions
+27
View File
@@ -0,0 +1,27 @@
/**
* Stripe — Transaction history
* ----------------------------
* Returns the payment records written by the webhook (the server-side source of
* truth). Reads from Vercel KV when connected; returns an empty list otherwise
* so the frontend degrades gracefully and falls back to its local record.
*
* GET /api/payments/transactions -> { transactions: [...] }
*/
export default async function handler(req, res) {
if (req.method !== 'GET') {
return res.status(405).json({ error: 'Method not allowed' });
}
try {
const { kv } = await import('@vercel/kv');
const raw = await kv.lrange('payments:transactions', 0, 199);
const transactions = (raw || []).map((item) =>
typeof item === 'string' ? JSON.parse(item) : item
);
return res.status(200).json({ transactions });
} catch {
// KV not configured — the frontend will use its local record instead.
return res.status(200).json({ transactions: [] });
}
}