70 lines
2.6 KiB
JavaScript
70 lines
2.6 KiB
JavaScript
const axios = require('axios');
|
|
|
|
// Test with EXACT same approach as gstService.js
|
|
async function testWithAxiosInstance() {
|
|
// Create a fresh axios instance (same as in gstService.js)
|
|
const axiosInstance = axios.create();
|
|
|
|
const providerUrl = 'https://dg-sandbox.setu.co/api/verify/gst';
|
|
const clientId = '292c6e76-dabf-49c4-8e48-90fba2916673';
|
|
const clientSecret = '7IZMe9zvoBBuBukLiCP7n4KLwSOy11oP';
|
|
const productInstanceId = '69e23f7f-4f71-412e-aec6-b1da3fb77c6f';
|
|
|
|
// Clean credentials (trim whitespace) - EXACT same as gstService.js
|
|
const cleanClientId = clientId.trim();
|
|
const cleanClientSecret = clientSecret.trim();
|
|
const cleanProductInstanceId = productInstanceId.trim();
|
|
const cleanUrl = providerUrl.trim();
|
|
|
|
const gstin = '29AABCT1332L1ZV';
|
|
|
|
console.log('Testing with axios instance (EXACT same as gstService.js)...\n');
|
|
console.log('Cleaned credentials:');
|
|
console.log(' URL:', cleanUrl);
|
|
console.log(' Client ID:', cleanClientId);
|
|
console.log(' Client Secret:', '****' + cleanClientSecret.slice(-4));
|
|
console.log(' Product Instance ID:', cleanProductInstanceId);
|
|
console.log(' GSTIN:', gstin);
|
|
console.log('\n---\n');
|
|
|
|
try {
|
|
const response = await axiosInstance.post(
|
|
cleanUrl,
|
|
{ gstin },
|
|
{
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Accept': 'application/json',
|
|
'x-client-id': cleanClientId,
|
|
'x-client-secret': cleanClientSecret,
|
|
'x-product-instance-id': cleanProductInstanceId
|
|
},
|
|
timeout: 30000
|
|
}
|
|
);
|
|
|
|
console.log('✅ SUCCESS!');
|
|
console.log('Status:', response.status);
|
|
console.log('Data:', JSON.stringify(response.data, null, 2));
|
|
|
|
} catch (error) {
|
|
if (error.response) {
|
|
console.log('❌ FAILED');
|
|
console.log('Status:', error.response.status);
|
|
console.log('Error:', JSON.stringify(error.response.data, null, 2));
|
|
console.log('\n---\n');
|
|
|
|
// Log the actual request that was sent
|
|
console.log('Request config:');
|
|
console.log(' URL:', error.config.url);
|
|
console.log(' Method:', error.config.method);
|
|
console.log(' Headers:', JSON.stringify(error.config.headers, null, 2));
|
|
console.log(' Data:', error.config.data);
|
|
} else {
|
|
console.log('❌ ERROR:', error.message);
|
|
}
|
|
}
|
|
}
|
|
|
|
testWithAxiosInstance();
|