/** * Script to check if PAN API configuration is correct * Usage: node scripts/check-pan-config.js */ require('dotenv').config(); console.log('\nšŸ” Checking PAN API Configuration...\n'); console.log('=' .repeat(60)); const requiredVars = [ 'PAN_PROVIDER_URL', 'PAN_CLIENT_ID', 'PAN_CLIENT_SECRET', 'PAN_PRODUCT_INSTANCE_ID' ]; let allSet = true; requiredVars.forEach(varName => { const value = process.env[varName]; if (value) { // Mask sensitive values if (varName === 'PAN_CLIENT_SECRET') { const masked = value.length > 10 ? value.substring(0, 4) + '***' + value.substring(value.length - 4) : '***'; console.log(`āœ… ${varName}: ${masked}`); } else { console.log(`āœ… ${varName}: ${value}`); } } else { console.log(`āŒ ${varName}: NOT SET`); allSet = false; } }); console.log('=' .repeat(60)); if (allSet) { console.log('\nāœ… All PAN API credentials are set!'); console.log('\nāš ļø If you still get "Bad token" errors:'); console.log(' 1. Double-check the credentials are correct'); console.log(' 2. Make sure you restarted the server after adding .env variables'); console.log(' 3. Verify the credentials in Setu dashboard\n'); } else { console.log('\nāŒ Missing PAN API credentials!'); console.log('\nšŸ“ Add these to your .env file:'); console.log(' PAN_PROVIDER_URL=https://dg-sandbox.setu.co/api/verify/pan'); console.log(' PAN_CLIENT_ID=your-client-id-here'); console.log(' PAN_CLIENT_SECRET=your-client-secret-here'); console.log(' PAN_PRODUCT_INSTANCE_ID=your-product-instance-id-here'); console.log('\nšŸ’” After adding, restart your server!\n'); } process.exit(allSet ? 0 : 1);