59 lines
1.9 KiB
JavaScript
59 lines
1.9 KiB
JavaScript
// Test script - run from project root: node test-direct-setu.js
|
|
require('dotenv').config();
|
|
const axios = require('axios');
|
|
|
|
async function testDirect() {
|
|
console.log('\n=== Testing Direct Setu API Call ===\n');
|
|
|
|
const clientId = process.env.PAN_CLIENT_ID;
|
|
const clientSecret = process.env.PAN_CLIENT_SECRET;
|
|
const productId = process.env.PAN_PRODUCT_INSTANCE_ID;
|
|
const url = process.env.PAN_PROVIDER_URL || 'https://dg-sandbox.setu.co/api/verify/pan';
|
|
|
|
console.log('Loaded from .env:');
|
|
console.log(' clientId:', clientId);
|
|
console.log(' clientSecret:', clientSecret ? '****' + clientSecret.slice(-4) : 'MISSING');
|
|
console.log(' productId:', productId);
|
|
console.log(' url:', url);
|
|
console.log('');
|
|
|
|
console.log('Testing with axios...');
|
|
|
|
try {
|
|
const response = await axios.post(
|
|
url,
|
|
{
|
|
pan: 'ABCDE1234A',
|
|
consent: 'Y',
|
|
reason: 'Testing PAN verification'
|
|
},
|
|
{
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Accept': 'application/json',
|
|
'x-client-id': clientId,
|
|
'x-client-secret': clientSecret,
|
|
'x-product-instance-id': productId
|
|
},
|
|
timeout: 30000
|
|
}
|
|
);
|
|
|
|
console.log('✅ SUCCESS!');
|
|
console.log('Status:', response.status);
|
|
console.log('Data:', JSON.stringify(response.data, null, 2));
|
|
|
|
} catch (error) {
|
|
console.log('❌ FAILED!');
|
|
if (error.response) {
|
|
console.log('Status:', error.response.status);
|
|
console.log('Data:', JSON.stringify(error.response.data, null, 2));
|
|
console.log('Headers:', JSON.stringify(error.response.headers, null, 2));
|
|
} else {
|
|
console.log('Error:', error.message);
|
|
}
|
|
}
|
|
}
|
|
|
|
testDirect();
|