Updated project changes

This commit is contained in:
2026-06-12 20:49:34 +05:30
parent aa87870350
commit f45955191f
13 changed files with 566 additions and 55 deletions
+18 -2
View File
@@ -38,8 +38,24 @@ export default async function handler(req, res) {
}
try {
const { invoiceId, customerEmail } = req.body || {};
const invoice = INVOICES[invoiceId];
const { invoiceId, customerEmail, fallback } = req.body || {};
// The static map is authoritative for seed invoices (amount can't be
// tampered). DEMO ONLY: invoices the owner created live in the browser's
// localStorage, so the server doesn't know them — accept the client's
// amount/title as a fallback for those. In production every invoice would
// be resolved from the billing DB here and this fallback removed.
let invoice = INVOICES[invoiceId];
if (!invoice && fallback) {
const amount = Number(fallback.amount);
if (Number.isInteger(amount) && amount > 0) {
invoice = {
title: String(fallback.title || 'Payment').slice(0, 200),
amount,
currency: (fallback.currency || 'usd').toLowerCase(),
};
}
}
if (!invoice) {
return res.status(404).json({ error: `Unknown invoice: ${invoiceId}` });
}