Fix portfolio ID validation to accept Wren API portfolio IDs
All checks were successful
Build and Push Docker Images / docker (push) Successful in 42s
All checks were successful
Build and Push Docker Images / docker (push) Successful in 42s
Changed backend validation from hardcoded [1, 2, 3] to accept any positive integer portfolio ID. The Wren API returns portfolios with their real IDs (not limited to 1-3), so the backend needs to accept dynamic portfolio IDs. - Changed validation to check for positive integers instead of [1, 2, 3] - Added logging to show which portfolio ID is being processed - Pricing calculation already has fallback to $18/ton for unknown IDs This fixes the "Invalid portfolio ID" error when trying to checkout. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5ec24af338
commit
0177707921
@ -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);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user