Verify_India_API/TEST_SETU_API_STEPS.md

3.4 KiB

Step-by-Step Guide: Testing Setu PAN API

This guide will help you test the Setu PAN API with static/hardcoded values.

Prerequisites

  1. Node.js installed - Make sure you have Node.js installed on your system
  2. Dependencies installed - All npm packages should be installed

Step-by-Step Instructions

Step 1: Navigate to the Project Directory

Open your terminal/command prompt and navigate to the project directory:

cd "C:\Users\front\Desktop\files 4\verify-india-api"

Step 2: Verify Dependencies are Installed

Check if node_modules folder exists. If not, install dependencies:

npm install

This will install all required packages including axios which is needed for the API call.

Step 3: Run the Test Script

You can run the test in two ways:

npm run test-setu-static

Option B: Direct node command

node scripts/test-setu-api-static.js

Step 4: Check the Results

The script will:

  • Show request details (URL, headers, body)
  • Send the request to Setu API
  • Display the response if successful
  • Show error details if it fails

Expected Output

Success Case:

🧪 Testing Setu PAN API with Static Values

======================================================================

📋 Request Details:
   URL: https://dg-sandbox.setu.co/api/verify/pan
   Method: POST
   ...

🚀 Sending request to Setu API...

✅ SUCCESS! API is working correctly!

======================================================================

📊 Response Details:
   Status Code: 200 OK
   Response Time: 1234ms
   ...

✅ Test completed successfully!

Error Case:

If there's an error, the script will show:

  • Status code
  • Error message
  • Possible issues and solutions

What the Script Tests

The script makes a POST request to Setu API with:

  • URL: https://dg-sandbox.setu.co/api/verify/pan
  • Headers:
    • Content-Type: application/json
    • x-client-id: 292c6e76-dabf-49c4-8e48-90fba2916673
    • x-client-secret: 7IZMe9zvoBBuBukLiCP7n4KLwSOy11oP
    • x-product-instance-id: 439244ff-114e-41a8-ae74-a783f160622d
  • Body:
    {
      "pan": "ABCDE1234A",
      "consent": "Y",
      "reason": "Testing"
    }
    

Troubleshooting

Error: "Cannot find module 'axios'"

Solution: Run npm install to install dependencies

Error: "Network Error" or "ECONNREFUSED"

Solution:

  • Check your internet connection
  • Verify the API URL is correct
  • Check if there's a firewall blocking the request

Error: "401 Unauthorized"

Solution:

  • Check if the client-id and client-secret are correct
  • Verify the credentials haven't expired

Error: "403 Forbidden"

Solution:

  • Check if the product-instance-id is correct
  • Verify you have access to this product instance

Error: "400 Bad Request"

Solution:

  • Check if the PAN format is correct (should be 10 characters: 5 letters, 4 digits, 1 letter)
  • Verify the request body structure

Next Steps

Once the test passes:

  1. Your Setu API credentials are working
  2. You can use these credentials in your .env file
  3. Your application can make PAN verification requests

Notes

  • This script uses static/hardcoded values - perfect for testing
  • The credentials are embedded in the script for testing purposes
  • For production, always use environment variables (.env file)
  • The script has a 30-second timeout for the API request