67 lines
2.2 KiB
Markdown
67 lines
2.2 KiB
Markdown
# GST Verification Setup Instructions
|
|
|
|
## Problem Identified ✅
|
|
|
|
The GST credentials you provided are **NOT in the `.env` file**. The environment variables are `undefined` when the app runs.
|
|
|
|
## Solution
|
|
|
|
You need to **add the following lines to your `.env` file**:
|
|
|
|
```env
|
|
# GST Verification (Setu)
|
|
GST_PROVIDER_URL=https://dg-sandbox.setu.co/api/verify/gst
|
|
GST_CLIENT_ID=292c6e76-dabf-49c4-8e48-90fba2916673
|
|
GST_CLIENT_SECRET=7IZMe9zvoBBuBukLiCP7n4KLwSOy11oP
|
|
GST_PRODUCT_INSTANCE_ID=69e23f7f-4f71-412e-aec6-b1da3fb77c6f
|
|
```
|
|
|
|
## Steps to Fix
|
|
|
|
1. **Open your `.env` file** (it's in the root of your project)
|
|
|
|
2. **Add the GST credentials** (copy the lines above)
|
|
|
|
3. **Restart your server**:
|
|
- Stop the current server (Ctrl+C in terminal)
|
|
- Run `npm run dev` again
|
|
|
|
4. **Test the endpoint** with this curl command:
|
|
|
|
### PowerShell (Windows):
|
|
```powershell
|
|
Invoke-WebRequest -Uri "http://localhost:3000/v1/gst/verify/27AAACM1234A1Z5" -Headers @{"x-api-key"="vf_test_369afc881da118c02ade27d323aaf3c186945edce6bcdf02"} -Method GET | Select-Object -ExpandProperty Content
|
|
```
|
|
|
|
### Bash/CMD (if you have curl.exe):
|
|
```bash
|
|
curl -X GET http://localhost:3000/v1/gst/verify/27AAACM1234A1Z5 -H "x-api-key: vf_test_369afc881da118c02ade27d323aaf3c186945edce6bcdf02"
|
|
```
|
|
|
|
## What I Fixed
|
|
|
|
1. ✅ **Applied the same fix that worked for PAN verification**:
|
|
- Created fresh axios instance to avoid global defaults pollution
|
|
- Clean credentials by trimming whitespace
|
|
- Added detailed debug logging
|
|
- Enhanced error handling for auth failures
|
|
|
|
2. ✅ **The code is ready** - it just needs the credentials in `.env`
|
|
|
|
## After Adding Credentials
|
|
|
|
Once you add the credentials to `.env` and restart, you should see:
|
|
|
|
**Debug logs in terminal:**
|
|
```
|
|
[GST Service] Sending request to provider: {
|
|
url: 'https://dg-sandbox.setu.co/api/verify/gst',
|
|
'x-client-id': '292c6e76-dabf-49c4-8e48-90fba2916673',
|
|
'x-client-secret': '****11oP',
|
|
'x-product-instance-id': '69e23f7f-4f71-412e-aec6-b1da3fb77c6f',
|
|
requestBody: { gstin: '27AAACM1234A1Z5' }
|
|
}
|
|
```
|
|
|
|
**Note**: If you still get authentication errors after adding to `.env`, it means the Setu sandbox credentials themselves are invalid or expired. You'll need to verify them with Setu.
|