diff --git a/server/routes/checkout.js b/server/routes/checkout.js index 28270f9..240ce75 100644 --- a/server/routes/checkout.js +++ b/server/routes/checkout.js @@ -47,10 +47,14 @@ router.post('/create-session', async (req, res) => { return res.status(400).json({ error: 'Invalid tons value' }); } - if (!portfolioId || ![1, 2, 3].includes(portfolioId)) { + // Accept any valid positive integer portfolio ID (from Wren API) + if (!portfolioId || !Number.isInteger(portfolioId) || portfolioId <= 0) { + console.error('❌ Invalid portfolio ID received:', portfolioId); return res.status(400).json({ error: 'Invalid portfolio ID' }); } + console.log(`📦 Creating checkout for portfolio ID: ${portfolioId}, tons: ${tons}`); + // Calculate pricing const { baseAmount, processingFee, totalAmount, pricePerTon } = calculatePricing(tons, portfolioId);