{
	"info": {
		"_postman_id": "12345678-1234-1234-1234-123456789012",
		"name": "INDI-VOUCH Backend APIs",
		"description": "Complete API collection for INDI-VOUCH Backend with user authentication, profile management, and system endpoints.",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "12345678"
	},
	"item": [
		{
			"name": "System APIs",
			"item": [
				{
					"name": "Welcome Message",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/",
							"host": [
								"{{base_url}}"
							],
							"path": [
								""
							]
						},
						"description": "Get welcome message and server status"
					},
					"response": []
				},
				{
					"name": "Health Check",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/health",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"health"
							]
						},
						"description": "Check server health and uptime"
					},
					"response": []
				},
				{
					"name": "Database Health Check",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/db-health",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"db-health"
							]
						},
						"description": "Check database connection status"
					},
					"response": []
				},
				{
					"name": "Get Database Tables",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/api/tables",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"tables"
							]
						},
						"description": "Get list of all database tables"
					},
					"response": []
				},
				{
					"name": "Get All Users (Legacy)",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/api/users",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"users"
							]
						},
						"description": "Get all users from database (legacy endpoint)"
					},
					"response": []
				}
			],
			"description": "System health checks and utility endpoints"
		},
		{
			"name": "User Authentication",
			"item": [
				{
					"name": "MLM User Registration",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"// Test for successful MLM registration",
									"pm.test(\"Status code is 201\", function () {",
									"    pm.response.to.have.status(201);",
									"});",
									"",
									"pm.test(\"Response has success property\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"});",
									"",
									"pm.test(\"Response contains userId and placement info\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('userId');",
									"    pm.expect(jsonData.data).to.have.property('username');",
									"    pm.expect(jsonData.data).to.have.property('sponsor_id');",
									"    pm.expect(jsonData.data).to.have.property('placement');",
									"});",
									"",
									"pm.test(\"Placement info is valid\", function () {",
									"    var jsonData = pm.response.json();",
									"    var placement = jsonData.data.placement;",
									"    pm.expect(placement).to.have.property('placed_under');",
									"    pm.expect(placement).to.have.property('position');",
									"    pm.expect(placement).to.have.property('type');",
									"    pm.expect(['left', 'right']).to.include(placement.position);",
									"    pm.expect(['direct', 'extreme']).to.include(placement.type);",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"John Doe\",\n  \"mobile\": \"9876543210\",\n  \"email\": \"john@example.com\",\n  \"sponsor_username\": \"{{test_sponsor_username}}\",\n  \"password\": \"secure123\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/user/auth/register",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"auth",
								"register"
							]
						},
						"description": "Register a new user in MLM system with sponsor. Username is auto-generated in format IN + 6 random digits (e.g., IN123456). Creates entries in user, user_status, generation, and binary_tree tables."
					},
					"response": []
				},
				{
					"name": "MLM Registration - Multiple Users",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"// Test for successful registration",
									"pm.test(\"Status code is 201\", function () {",
									"    pm.response.to.have.status(201);",
									"});",
									"",
									"pm.test(\"Binary tree placement working\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.data.placement).to.exist;",
									"    console.log('Placement:', JSON.stringify(jsonData.data.placement, null, 2));",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"Jane Smith\",\n  \"mobile\": \"9876543211\",\n  \"email\": \"jane@example.com\",\n  \"sponsor_username\": \"{{test_sponsor_username}}\",\n  \"password\": \"secure123\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/user/auth/register",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"auth",
								"register"
							]
						},
						"description": "Register second user under same sponsor to test binary tree placement logic"
					},
					"response": []
				},
				{
					"name": "User Login (Username)",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"// Test for successful login",
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has token\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('token');",
									"    ",
									"    // Save token to environment variable",
									"    if (jsonData.data.token) {",
									"        pm.environment.set('auth_token', jsonData.data.token);",
									"    }",
									"});",
									"",
									"pm.test(\"Response contains user data\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('user');",
									"    pm.expect(jsonData.data.user).to.have.property('id');",
									"    pm.expect(jsonData.data.user).to.have.property('username');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"username\": \"john_doe\",\n  \"password\": \"secure123\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/user/auth/login",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"auth",
								"login"
							]
						},
						"description": "Login user with username and password"
					},
					"response": []
				},
				{
					"name": "User Login (Email)",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"// Test for successful login",
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has token\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('token');",
									"    ",
									"    // Save token to environment variable",
									"    if (jsonData.data.token) {",
									"        pm.environment.set('auth_token', jsonData.data.token);",
									"    }",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"email\": \"john@example.com\",\n  \"password\": \"secure123\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/user/auth/login",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"auth",
								"login"
							]
						},
						"description": "Login user with email and password"
					},
					"response": []
				},
				{
					"name": "User Login (Mobile)",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"// Test for successful login",
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has token\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('token');",
									"    ",
									"    // Save token to environment variable",
									"    if (jsonData.data.token) {",
									"        pm.environment.set('auth_token', jsonData.data.token);",
									"    }",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"mobile\": \"9876543210\",\n  \"password\": \"secure123\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/user/auth/login",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"auth",
								"login"
							]
						},
						"description": "Login user with mobile number and password"
					},
					"response": []
				},
				{
					"name": "User Login (Deactivated User)",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"// Test that deactivated users can still login",
									"pm.test(\"Deactivated user can login\", function () {",
									"    // This should succeed even if user status is 0",
									"    pm.expect(pm.response.code).to.be.oneOf([200, 401]);",
									"    ",
									"    if (pm.response.code === 200) {",
									"        var jsonData = pm.response.json();",
									"        pm.expect(jsonData.success).to.be.true;",
									"        pm.expect(jsonData.data).to.have.property('token');",
									"    }",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"username\": \"deactivated_user\",\n  \"password\": \"secure123\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/user/auth/login",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"auth",
								"login"
							]
						},
						"description": "Test login with deactivated user (status = 0). Should succeed."
					},
					"response": []
				}
			],
			"description": "User registration and login endpoints"
		},
		{
			"name": "User Profile Management",
			"item": [
				{
					"name": "Get User Profile",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response contains user profile\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('id');",
									"    pm.expect(jsonData.data).to.have.property('name');",
									"    pm.expect(jsonData.data).to.have.property('username');",
									"    pm.expect(jsonData.data).to.have.property('email');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"description": "JWT token from login"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/user/profile",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"profile"
							]
						},
						"description": "Get current user's profile information (requires authentication)"
					},
					"response": []
				},
				{
					"name": "Update User Profile",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Profile updated successfully\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"    pm.expect(jsonData.message).to.include('updated');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "PUT",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"description": "JWT token from login"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"John Smith\",\n  \"email\": \"johnsmith@example.com\",\n  \"mobile\": \"9876543211\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/user/profile",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"profile"
							]
						},
						"description": "Update current user's profile information (requires authentication)"
					},
					"response": []
				},
				{
					"name": "Update Profile (with Password)",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has success property\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData).to.have.property('success');",
									"    pm.expect(jsonData.success).to.be.true;",
									"});",
									"",
									"pm.test(\"Profile updated successfully\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.message).to.include('updated successfully');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "PUT",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"type": "text"
							},
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"Updated Name\",\n  \"email\": \"updated@email.com\",\n  \"mobile\": \"9876543210\",\n  \"password\": \"newpassword123\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/user/profile",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"profile"
							]
						},
						"description": "Update user profile including password change (requires authentication)"
					},
					"response": []
				}
			],
			"description": "User profile management endpoints (require authentication)"
		},
		{
			"name": "Admin Authentication",
			"item": [
				{
					"name": "Admin Login (Not Implemented)",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"username\": \"admin\",\n  \"password\": \"admin123\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/admin/auth/login",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"admin",
								"auth",
								"login"
							]
						},
						"description": "Admin login endpoint (currently returns 501 - Not Implemented)"
					},
					"response": []
				}
			],
			"description": "Admin authentication endpoints (placeholder)"
		},
		{
			"name": "Error Testing",
			"item": [
				{
					"name": "Invalid Login Credentials",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 401\", function () {",
									"    pm.response.to.have.status(401);",
									"});",
									"",
									"pm.test(\"Error message for invalid credentials\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.false;",
									"    pm.expect(jsonData.message).to.include('Invalid credentials');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"username\": \"nonexistent_user\",\n  \"password\": \"wrong_password\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/user/auth/login",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"auth",
								"login"
							]
						},
						"description": "Test login with invalid credentials"
					},
					"response": []
				},
				{
					"name": "Access Profile Without Token",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 401\", function () {",
									"    pm.response.to.have.status(401);",
									"});",
									"",
									"pm.test(\"Error message for missing token\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.false;",
									"    pm.expect(jsonData.message).to.include('No token provided');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/api/user/profile",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"profile"
							]
						},
						"description": "Test accessing protected endpoint without authentication token"
					},
					"response": []
				},
				{
					"name": "Register with Duplicate Username",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 409\", function () {",
									"    pm.response.to.have.status(409);",
									"});",
									"",
									"pm.test(\"Error message for duplicate user\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.false;",
									"    pm.expect(jsonData.message).to.include('already exists');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"Another User\",\n  \"username\": \"john_doe\",\n  \"email\": \"another@example.com\",\n  \"mobile\": \"9876543211\",\n  \"password\": \"secure123\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/user/auth/register",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"auth",
								"register"
							]
						},
						"description": "Test registration with duplicate username"
					},
					"response": []
				},
				{
					"name": "Register with Short Password",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 400\", function () {",
									"    pm.response.to.have.status(400);",
									"});",
									"",
									"pm.test(\"Error message for short password\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.false;",
									"    pm.expect(jsonData.message).to.include('6 characters');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"Test User\",\n  \"mobile\": \"9876543212\",\n  \"email\": \"test@example.com\",\n  \"sponsor_username\": \"{{test_sponsor_username}}\",\n  \"password\": \"123\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/user/auth/register",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"auth",
								"register"
							]
						},
						"description": "Test MLM registration with password shorter than 6 characters"
					},
					"response": []
				},
				{
					"name": "Register with Invalid Sponsor",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 400\", function () {",
									"    pm.response.to.have.status(400);",
									"});",
									"",
									"pm.test(\"Error message for invalid sponsor\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.false;",
									"    pm.expect(jsonData.message).to.include('Sponsor username not found');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"Test User\",\n  \"mobile\": \"9876543213\",\n  \"email\": \"test2@example.com\",\n  \"sponsor_username\": \"nonexistent_sponsor\",\n  \"password\": \"secure123\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/user/auth/register",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"auth",
								"register"
							]
						},
						"description": "Test MLM registration with non-existent sponsor username"
					},
					"response": []
				},
				{
					"name": "Register with Missing Fields",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 400\", function () {",
									"    pm.response.to.have.status(400);",
									"});",
									"",
									"pm.test(\"Error message for missing fields\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.false;",
									"    pm.expect(jsonData.message).to.include('All fields are required');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"Test User\",\n  \"mobile\": \"9876543214\",\n  \"email\": \"test3@example.com\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/user/auth/register",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"auth",
								"register"
							]
						},
						"description": "Test MLM registration with missing sponsor_username and password"
					},
					"response": []
				}
			],
			"description": "Test error scenarios and validation"
		},
		{
			"name": "Commission & Wallet APIs",
			"item": [
				{
					"name": "Get Wallet Balances",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has wallet balances\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"    pm.expect(jsonData.data).to.have.property('commission_wallet');",
									"    pm.expect(jsonData.data).to.have.property('repurchase_wallet');",
									"    pm.expect(jsonData.data).to.have.property('total_balance');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/commission/wallet/balance",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"commission",
								"wallet",
								"balance"
							]
						},
						"description": "Get user's commission and repurchase wallet balances"
					},
					"response": []
				},
				{
					"name": "Get Commission Wallet Balance",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has commission balance\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"    pm.expect(jsonData.data).to.have.property('balance');",
									"    pm.expect(jsonData.data.wallet_type).to.equal('commission');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/commission/wallet/balance/commission",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"commission",
								"wallet",
								"balance",
								"commission"
							]
						},
						"description": "Get user's commission wallet balance only"
					},
					"response": []
				},
				{
					"name": "Get Repurchase Wallet Balance",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has repurchase balance\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"    pm.expect(jsonData.data).to.have.property('balance');",
									"    pm.expect(jsonData.data.wallet_type).to.equal('repurchase');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/commission/wallet/balance/repurchase",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"commission",
								"wallet",
								"balance",
								"repurchase"
							]
						},
						"description": "Get user's repurchase wallet balance only"
					},
					"response": []
				},
				{
					"name": "Get Commission History",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has transaction history\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"    pm.expect(jsonData.data).to.have.property('transactions');",
									"    pm.expect(jsonData.data).to.have.property('count');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/commission/history?limit=20",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"commission",
								"history"
							],
							"query": [
								{
									"key": "limit",
									"value": "20"
								}
							]
						},
						"description": "Get user's commission transaction history"
					},
					"response": []
				},
				{
					"name": "Get Commission Wallet Transactions",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has transactions data\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('transactions');",
									"    pm.expect(jsonData.data).to.have.property('current_balance');",
									"    pm.expect(jsonData.data).to.have.property('wallet_type', 'commission');",
									"    pm.expect(jsonData.data).to.have.property('filters');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/commission/transactions/commission?limit=20&offset=0&sort=desc&from_date=2025-11-01&to_date=2025-11-02",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"commission",
								"transactions",
								"commission"
							],
							"query": [
								{
									"key": "limit",
									"value": "20",
									"description": "Number of transactions per page"
								},
								{
									"key": "offset",
									"value": "0",
									"description": "Starting position for pagination"
								},
								{
									"key": "sort",
									"value": "desc",
									"description": "Sort order: 'asc' or 'desc'"
								},
								{
									"key": "from_date",
									"value": "2025-11-01",
									"description": "Start date (YYYY-MM-DD format)"
								},
								{
									"key": "to_date",
									"value": "2025-11-02",
									"description": "End date (YYYY-MM-DD format)"
								}
							]
						},
						"description": "Get commission wallet transactions with date filtering and sorting"
					},
					"response": []
				},
				{
					"name": "Get Repurchase Wallet Transactions",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has transactions data\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('transactions');",
									"    pm.expect(jsonData.data).to.have.property('current_balance');",
									"    pm.expect(jsonData.data).to.have.property('wallet_type', 'repurchase');",
									"    pm.expect(jsonData.data).to.have.property('filters');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/commission/transactions/repurchase?limit=20&offset=0&sort=desc&from_date=2025-11-01&to_date=2025-11-02",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"commission",
								"transactions",
								"repurchase"
							],
							"query": [
								{
									"key": "limit",
									"value": "20",
									"description": "Number of transactions per page"
								},
								{
									"key": "offset",
									"value": "0",
									"description": "Starting position for pagination"
								},
								{
									"key": "sort",
									"value": "desc",
									"description": "Sort order: 'asc' or 'desc'"
								},
								{
									"key": "from_date",
									"value": "2025-11-01",
									"description": "Start date (YYYY-MM-DD format)"
								},
								{
									"key": "to_date",
									"value": "2025-11-02",
									"description": "End date (YYYY-MM-DD format)"
								}
							]
						},
						"description": "Get repurchase wallet transactions with date filtering and sorting"
					},
					"response": []
				},
				{
					"name": "Get All Wallet Transactions",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has transactions and wallet balances\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('transactions');",
									"    pm.expect(jsonData.data).to.have.property('wallet_balances');",
									"    pm.expect(jsonData.data.wallet_balances).to.have.property('commission_wallet');",
									"    pm.expect(jsonData.data.wallet_balances).to.have.property('repurchase_wallet');",
									"    pm.expect(jsonData.data).to.have.property('filters');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/commission/transactions?limit=20&offset=0&sort=desc&from_date=2025-11-01&to_date=2025-11-02",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"commission",
								"transactions"
							],
							"query": [
								{
									"key": "limit",
									"value": "20",
									"description": "Number of transactions per page"
								},
								{
									"key": "offset",
									"value": "0",
									"description": "Starting position for pagination"
								},
								{
									"key": "sort",
									"value": "desc",
									"description": "Sort order: 'asc' or 'desc'"
								},
								{
									"key": "from_date",
									"value": "2025-11-01",
									"description": "Start date (YYYY-MM-DD format)"
								},
								{
									"key": "to_date",
									"value": "2025-11-02",
									"description": "End date (YYYY-MM-DD format)"
								}
							]
						},
						"description": "Get all wallet transactions (commission + repurchase) with date filtering and sorting"
					},
					"response": []
				}
			],
			"description": "Commission and wallet management APIs"
		},
		{
			"name": "Purchase & Stock APIs",
			"item": [
				{
					"name": "Get Available Packages",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has packages data\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('packages');",
									"    pm.expect(jsonData.data.packages).to.be.an('array');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/api/purchase/packages",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"purchase",
								"packages"
							]
						}
					},
					"response": []
				},
				{
					"name": "Get Package Details",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200 or 404\", function () {",
									"    pm.expect(pm.response.code).to.be.oneOf([200, 404]);",
									"});",
									"",
									"if (pm.response.code === 200) {",
									"    pm.test(\"Response has package data\", function () {",
									"        const jsonData = pm.response.json();",
									"        pm.expect(jsonData.data).to.have.property('id');",
									"        pm.expect(jsonData.data).to.have.property('name');",
									"        pm.expect(jsonData.data).to.have.property('amount');",
									"    });",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/api/purchase/packages/1",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"purchase",
								"packages",
								"1"
							]
						}
					},
					"response": []
				},
				{
					"name": "Get Repurchase Wallet Balance (Purchase)",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has balance data\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('repurchase_balance');",
									"    pm.expect(jsonData.data.repurchase_balance).to.be.a('number');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/purchase/wallet/repurchase",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"purchase",
								"wallet",
								"repurchase"
							]
						}
					},
					"response": []
				},
				{
					"name": "Purchase Package",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 201, 400, 402, or 404\", function () {",
									"    pm.expect(pm.response.code).to.be.oneOf([201, 400, 402, 404]);",
									"});",
									"",
									"if (pm.response.code === 201) {",
									"    pm.test(\"Purchase successful\", function () {",
									"        const jsonData = pm.response.json();",
									"        pm.expect(jsonData.success).to.be.true;",
									"        pm.expect(jsonData.data).to.have.property('stock_id');",
									"        pm.expect(jsonData.data).to.have.property('total_cost');",
									"    });",
									"} else if (pm.response.code === 402) {",
									"    pm.test(\"Insufficient balance error\", function () {",
									"        const jsonData = pm.response.json();",
									"        pm.expect(jsonData.message).to.include('Insufficient');",
									"        pm.expect(jsonData.data).to.have.property('shortage');",
									"    });",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"type": "text"
							},
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"package_id\": 1,\n  \"quantity\": 1\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/purchase/buy",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"purchase",
								"buy"
							]
						}
					},
					"response": []
				},
				{
					"name": "Get Purchase History",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has purchase history\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('purchases');",
									"    pm.expect(jsonData.data.purchases).to.be.an('array');",
									"    pm.expect(jsonData.data).to.have.property('count');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/purchase/history?limit=20",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"purchase",
								"history"
							],
							"query": [
								{
									"key": "limit",
									"value": "20"
								}
							]
						}
					},
					"response": []
				},
				{
					"name": "Admin - Get All Purchases",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200 or 403\", function () {",
									"    pm.expect(pm.response.code).to.be.oneOf([200, 403]);",
									"});",
									"",
									"if (pm.response.code === 200) {",
									"    pm.test(\"Response has all purchases data\", function () {",
									"        const jsonData = pm.response.json();",
									"        pm.expect(jsonData.data).to.have.property('purchases');",
									"        pm.expect(jsonData.data.purchases).to.be.an('array');",
									"    });",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{admin_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/purchase/admin/all?limit=50",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"purchase",
								"admin",
								"all"
							],
							"query": [
								{
									"key": "limit",
									"value": "50"
								}
							]
						}
					},
					"response": []
				}
			],
			"description": "Purchase and stock management APIs"
		},
		{
			"name": "Settings & Flag APIs",
			"item": [
				{
					"name": "Get Flag Value",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200 or 404\", function () {",
									"    pm.expect(pm.response.code).to.be.oneOf([200, 404]);",
									"});",
									"",
									"if (pm.response.code === 200) {",
									"    pm.test(\"Response has flag value\", function () {",
									"        var jsonData = pm.response.json();",
									"        pm.expect(jsonData.success).to.be.true;",
									"        pm.expect(jsonData.data).to.have.property('flag_name');",
									"        pm.expect(jsonData.data).to.have.property('flag_value');",
									"    });",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/api/settings/flag/referal_reward_on_joining",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"settings",
								"flag",
								"referal_reward_on_joining"
							]
						},
						"description": "Get specific flag value from settings table"
					},
					"response": []
				},
				{
					"name": "Get Multiple Flag Values",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has flag values\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"    pm.expect(jsonData.data).to.have.property('flag_values');",
									"    pm.expect(jsonData.data).to.have.property('found_count');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"flag_names\": [\n    \"referal_reward_on_joining\",\n    \"app_name\",\n    \"commission_status\"\n  ]\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/settings/flags",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"settings",
								"flags"
							]
						},
						"description": "Get multiple flag values at once"
					},
					"response": []
				},
				{
					"name": "Check Stock Table Structure",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has table structure\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"    pm.expect(jsonData.structure).to.be.an('array');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/api/debug/stock-structure",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"debug",
								"stock-structure"
							]
						}
					},
					"response": []
				},
				{
					"name": "Check Voucher Packages Table Structure",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has table structure\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"    pm.expect(jsonData.structure).to.be.an('array');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/api/debug/voucher_packages-structure",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"debug",
								"voucher_packages-structure"
							]
						}
					},
					"response": []
				},
				{
					"name": "Check F_Payment Table Structure",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has table structure\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"    pm.expect(jsonData.structure).to.be.an('array');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/api/debug/f_payment-structure",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"debug",
								"f_payment-structure"
							]
						}
					},
					"response": []
				},
				{
					"name": "Get All Settings",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has settings\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"    pm.expect(jsonData.data).to.have.property('settings');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/api/settings",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"settings"
							]
						},
						"description": "Get all application settings"
					},
					"response": []
				},
				{
					"name": "Test Complete Purchase Flow",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"// This test demonstrates the complete purchase flow",
									"console.log('Testing complete purchase flow...');"
								],
								"type": "text/javascript"
							}
						},
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Purchase flow test completed\", function () {",
									"    // This is a comprehensive test that should be run after:",
									"    // 1. User has repurchase wallet balance",
									"    // 2. Packages exist in voucher_packages table",
									"    // 3. User is authenticated",
									"    pm.expect(pm.response.code).to.be.oneOf([201, 402, 404]);",
									"});",
									"",
									"if (pm.response.code === 201) {",
									"    pm.test(\"Purchase successful - check stock and payment\", function () {",
									"        const jsonData = pm.response.json();",
									"        pm.expect(jsonData.success).to.be.true;",
									"        pm.expect(jsonData.data.stock_id).to.be.a('number');",
									"        console.log('✅ Purchase completed successfully');",
									"        console.log('Stock ID:', jsonData.data.stock_id);",
									"        console.log('Total Cost:', jsonData.data.total_cost);",
									"        console.log('Remaining Balance:', jsonData.data.remaining_balance);",
									"    });",
									"} else if (pm.response.code === 402) {",
									"    pm.test(\"Insufficient balance - expected behavior\", function () {",
									"        const jsonData = pm.response.json();",
									"        console.log('⚠️ Insufficient balance - add funds to repurchase wallet');",
									"        console.log('Required:', jsonData.data.required_amount);",
									"        console.log('Available:', jsonData.data.available_balance);",
									"        console.log('Shortage:', jsonData.data.shortage);",
									"    });",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"type": "text"
							},
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"package_id\": 1,\n  \"quantity\": 2\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/purchase/buy",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"purchase",
								"buy"
							]
						}
					},
					"response": []
				}
			],
			"description": "Purchase and stock management APIs"
		},
		{
			"name": "Debug & Development APIs",
			"item": [
				{
					"name": "Check Payment Table Structure",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has table structure\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"    pm.expect(jsonData.structure).to.be.an('array');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/api/debug/payment-structure",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"debug",
								"payment-structure"
							]
						},
						"description": "Check payment table structure for commission system"
					},
					"response": []
				},
				{
					"name": "Test Registration with Commission",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 201\", function () {",
									"    pm.response.to.have.status(201);",
									"});",
									"",
									"pm.test(\"Registration successful with commission info\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"    pm.expect(jsonData.data).to.have.property('userId');",
									"    pm.expect(jsonData.data).to.have.property('commission');",
									"    ",
									"    // Save user ID for other tests",
									"    if (jsonData.data.userId) {",
									"        pm.environment.set('test_user_id', jsonData.data.userId);",
									"    }",
									"});",
									"",
									"pm.test(\"Commission processing info present\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.data.commission).to.have.property('success');",
									"    pm.expect(jsonData.data.commission).to.have.property('processed');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"Commission Test User\",\n  \"mobile\": \"9876543299\",\n  \"email\": \"commissiontest@example.com\",\n  \"sponsor_username\": \"{{test_sponsor_username}}\",\n  \"password\": \"secure123\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/user/auth/register",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"user",
								"auth",
								"register"
							]
						},
						"description": "Test MLM registration with commission processing"
					},
					"response": []
				},
				{
					"name": "Debug Commission Setup",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has debug info\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('user_exists');",
									"    pm.expect(jsonData.data).to.have.property('sponsor_exists_in_generation');",
									"    pm.expect(jsonData.data).to.have.property('commission_flag_exists');",
									"    pm.expect(jsonData.data).to.have.property('ready_for_commission');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/api/purchase/debug/commission-setup/10",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"purchase",
								"debug",
								"commission-setup",
								"10"
							]
						},
						"description": "Debug commission setup for troubleshooting purchase commission issues"
					},
					"response": []
				}
			],
			"description": "Debug and development endpoints"
		},
		{
			"name": "Team Management APIs",
			"item": [
				{
					"name": "Get Direct Team Members",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has team members data\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('members');",
									"    pm.expect(jsonData.data).to.have.property('total_direct_members');",
									"    pm.expect(jsonData.data).to.have.property('pagination');",
									"});",
									"",
									"pm.test(\"Members have required fields\", function () {",
									"    const jsonData = pm.response.json();",
									"    if (jsonData.data.members.length > 0) {",
									"        const member = jsonData.data.members[0];",
									"        pm.expect(member).to.have.property('name');",
									"        pm.expect(member).to.have.property('username');",
									"        pm.expect(member).to.have.property('mobile');",
									"        pm.expect(member).to.have.property('joining_date');",
									"        pm.expect(member).to.have.property('joining_date_formatted');",
									"        pm.expect(member).to.have.property('status_text');",
									"        pm.expect(member).to.have.property('member_type');",
									"        // Check mobile masking",
									"        pm.expect(member.mobile).to.match(/^\\*{5}/);",
									"        // Check status values",
									"        pm.expect(member.status_text).to.be.oneOf(['Active', 'Inactive']);",
									"        pm.expect(member.member_type).to.be.oneOf(['Paid Member', 'Free Member']);",
									"    }",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/team/direct-members?limit=20&offset=0",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"team",
								"direct-members"
							],
							"query": [
								{
									"key": "limit",
									"value": "20",
									"description": "Number of members per page"
								},
								{
									"key": "offset",
									"value": "0",
									"description": "Starting position for pagination"
								}
							]
						},
						"description": "Get direct team members with masked mobile numbers and formatted joining dates"
					},
					"response": []
				},
				{
					"name": "Get Team Member Details",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200 or 404\", function () {",
									"    pm.expect(pm.response.code).to.be.oneOf([200, 404]);",
									"});",
									"",
									"if (pm.response.code === 200) {",
									"    pm.test(\"Response has member details\", function () {",
									"        const jsonData = pm.response.json();",
									"        pm.expect(jsonData.data).to.have.property('name');",
									"        pm.expect(jsonData.data).to.have.property('username');",
									"        pm.expect(jsonData.data).to.have.property('mobile');",
									"        pm.expect(jsonData.data).to.have.property('email');",
									"        pm.expect(jsonData.data).to.have.property('joining_date');",
									"        pm.expect(jsonData.data).to.have.property('status_text');",
									"        pm.expect(jsonData.data).to.have.property('member_type');",
									"        // Check mobile masking",
									"        pm.expect(jsonData.data.mobile).to.match(/^\\*{5}/);",
									"        // Check status values",
									"        pm.expect(jsonData.data.status_text).to.be.oneOf(['Active', 'Inactive']);",
									"        pm.expect(jsonData.data.member_type).to.be.oneOf(['Paid Member', 'Free Member']);",
									"    });",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/team/member/10",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"team",
								"member",
								"10"
							]
						},
						"description": "Get detailed information about a specific team member"
					},
					"response": []
				},
				{
					"name": "Get Team Statistics",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has team statistics\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('statistics');",
									"    pm.expect(jsonData.data.statistics).to.have.property('total_direct_members');",
									"    pm.expect(jsonData.data.statistics).to.have.property('active_direct_members');",
									"    pm.expect(jsonData.data.statistics).to.have.property('free_direct_members');",
									"    pm.expect(jsonData.data.statistics).to.have.property('inactive_direct_members');",
									"    pm.expect(jsonData.data.statistics).to.have.property('recent_joinings_30_days');",
									"});",
									"",
									"pm.test(\"Statistics are numbers\", function () {",
									"    const jsonData = pm.response.json();",
									"    const stats = jsonData.data.statistics;",
									"    pm.expect(stats.total_direct_members).to.be.a('number');",
									"    pm.expect(stats.active_direct_members).to.be.a('number');",
									"    pm.expect(stats.free_direct_members).to.be.a('number');",
									"    pm.expect(stats.inactive_direct_members).to.be.a('number');",
									"    pm.expect(stats.recent_joinings_30_days).to.be.a('number');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/team/stats",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"team",
								"stats"
							]
						},
						"description": "Get team statistics including total, active, inactive members and recent joinings"
					},
					"response": []
				}
			],
			"description": "Team management and downline tracking APIs"
		},
		{
			"name": "Payment APIs",
			"item": [
				{
					"name": "Create Payment Order",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 201\", function () {",
									"    pm.response.to.have.status(201);",
									"});",
									"",
									"pm.test(\"Response has payment order data\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('payment_id');",
									"    pm.expect(jsonData.data).to.have.property('amount');",
									"    pm.expect(jsonData.data).to.have.property('status', 'Pending');",
									"    pm.expect(jsonData.data).to.have.property('qr_code');",
									"});",
									"",
									"pm.test(\"Save payment_id for other tests\", function () {",
									"    const jsonData = pm.response.json();",
									"    if (jsonData.data && jsonData.data.payment_id) {",
									"        pm.environment.set('test_payment_id', jsonData.data.payment_id);",
									"    }",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"type": "text"
							},
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"amount\": 1000\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/payment/create-order",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"payment",
								"create-order"
							]
						},
						"description": "Create a new payment order for wallet recharge"
					},
					"response": []
				},
				{
					"name": "Check Payment Status",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has payment status\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('payment_id');",
									"    pm.expect(jsonData.data).to.have.property('status');",
									"    pm.expect(jsonData.data).to.have.property('amount');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/payment/status/{{test_payment_id}}",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"payment",
								"status",
								"{{test_payment_id}}"
							]
						},
						"description": "Check payment status"
					},
					"response": []
				},
				{
					"name": "Update Payment Status and Wallet",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has update result\", function () {",
									"    const jsonData = pm.response.json();",
									"    pm.expect(jsonData.data).to.have.property('payment_id');",
									"    pm.expect(jsonData.data).to.have.property('status');",
									"    pm.expect(jsonData.data).to.have.property('wallet_updated');",
									"});",
									"",
									"pm.test(\"If completed, wallet should be updated\", function () {",
									"    const jsonData = pm.response.json();",
									"    if (jsonData.data.status === 'Completed') {",
									"        pm.expect(jsonData.data.wallet_updated).to.be.true;",
									"        pm.expect(jsonData.data).to.have.property('new_wallet_balance');",
									"    }",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{auth_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/payment/check-and-update/{{test_payment_id}}",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"payment",
								"check-and-update",
								"{{test_payment_id}}"
							]
						},
						"description": "Check payment status and update wallet if successful"
					},
					"response": []
				}
			],
			"description": "Essential payment APIs for wallet recharge"
		},
		{
			"name": "Admin Commission APIs",
			"item": [
				{
					"name": "Manual Commission Payment",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Commission payment successful\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"    pm.expect(jsonData.data).to.have.property('amount');",
									"    pm.expect(jsonData.data).to.have.property('commission_type');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{admin_token}}"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"user_id\": 1,\n  \"amount\": 50.00,\n  \"commission_type\": \"Manual Bonus\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/commission/admin/pay",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"commission",
								"admin",
								"pay"
							]
						},
						"description": "Admin manually pay commission to user"
					},
					"response": []
				},
				{
					"name": "Manual Wallet Deduction",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Deduction successful\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData.success).to.be.true;",
									"    pm.expect(jsonData.data).to.have.property('amount');",
									"    pm.expect(jsonData.data).to.have.property('deduction_type');",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{admin_token}}"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"user_id\": 1,\n  \"amount\": 25.00,\n  \"deduction_type\": \"Manual Adjustment\",\n  \"wallet_type\": 1\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/commission/admin/deduct",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"commission",
								"admin",
								"deduct"
							]
						},
						"description": "Admin manually deduct amount from user wallet"
					},
					"response": []
				}
			],
			"description": "Admin commission management APIs (requires admin authentication)"
		},
		{
			"name": "Voucher APIs",
			"item": [
				{
					"name": "Get Voucher Types",
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{base_url}}/api/voucher/types",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"voucher",
								"types"
							]
						},
						"description": "Get all available voucher types (public endpoint)"
					},
					"response": []
				},
				{
					"name": "Create Voucher Slots",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{user_token}}",
								"type": "text"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"voucher_type_id\": 1,\n  \"quantity\": 5\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/voucher/create-slots",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"voucher",
								"create-slots"
							]
						},
						"description": "Create voucher slots using commission wallet balance. Automatically deducts the total cost from user's commission wallet."
					},
					"response": []
				},
				{
					"name": "Get My Vouchers",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{user_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/voucher/my-vouchers",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"voucher",
								"my-vouchers"
							]
						},
						"description": "Get all vouchers belonging to logged-in user with statistics"
					},
					"response": []
				},
				{
					"name": "Get My Vouchers (Unused Only)",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{user_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/voucher/my-vouchers?status=Unused",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"voucher",
								"my-vouchers"
							],
							"query": [
								{
									"key": "status",
									"value": "Unused"
								}
							]
						},
						"description": "Get only unused vouchers for logged-in user"
					},
					"response": []
				},
				{
					"name": "Get My Vouchers (Used Only)",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{user_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/voucher/my-vouchers?status=Used",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"voucher",
								"my-vouchers"
							],
							"query": [
								{
									"key": "status",
									"value": "Used"
								}
							]
						},
						"description": "Get only used vouchers for logged-in user"
					},
					"response": []
				},
				{
					"name": "Update Voucher Status",
					"request": {
						"method": "PUT",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{user_token}}",
								"type": "text"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"voucher_id\": 1,\n  \"new_status\": \"Used\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/api/voucher/update-status",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"voucher",
								"update-status"
							]
						},
						"description": "Update voucher status (User can only update their own vouchers). Valid statuses: Unused, Used, Expired, Cancelled"
					},
					"response": []
				},
				{
					"name": "Get Voucher Details",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{user_token}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/voucher/details/1",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"voucher",
								"details",
								"1"
							]
						},
						"description": "Get specific voucher details by ID (User can only view their own vouchers)"
					},
					"response": []
				}
			],
			"description": "Voucher management APIs - Create, view, and update vouchers using commission wallet"
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"exec": [
					"// Global pre-request script",
					"console.log('Making request to: ' + pm.request.url);"
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"exec": [
					"// Global test script",
					"pm.test('Response time is less than 5000ms', function () {",
					"    pm.expect(pm.response.responseTime).to.be.below(5000);",
					"});",
					"",
					"pm.test('Response has JSON content-type', function () {",
					"    pm.expect(pm.response.headers.get('Content-Type')).to.include('application/json');",
					"});"
				]
			}
		}
	],
	"variable": [
		{
			"key": "base_url",
			"value": "http://localhost:3000",
			"type": "string"
		}
	]
}
