Verify_India_API/scripts/check-pan-config.js

58 lines
1.7 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 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);