// File: postman/collection-json/users.postman_collection.json

{
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    },
    {
      "listen": "test",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "item": [
    {
      "name": "Health check",
      "item": [
        {
          "name": "New Request",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "// Validate status 2xx",
                  "pm.test(\"[POST]::/health - Status code is 2xx\", function () {",
                  "  pm.response.to.be.success;",
                  "});",
                  ""
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/health",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "health"
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Flow Testcases",
      "item": [
        {
          "name": "Sign Up",
          "item": [
            {
              "name": "Connect Account",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "console.log(\"[LOG]::x-request-id - \" + pm.response.headers.get(\"x-request-id\"));",
                      "",
                      "// Validate status 2xx",
                      "pm.test(\"[POST]::/user/connect_account - Status code is 2xx\", function () {",
                      "  pm.response.to.be.success;",
                      "});",
                      "",
                      "// Validate if response header has matching content-type",
                      "pm.test(\"[POST]::/user/connect_account - Content-Type is application/json\", function () {",
                      "  pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(",
                      "    \"application/json\",",
                      "  );",
                      "});",
                      "",
                      "// Validate if response has JSON Body",
                      "pm.test(\"[POST]::/user/connect_account - Response has JSON Body\", function () {",
                      "  pm.response.to.have.jsonBody();",
                      "});",
                      "",
                      "// Validate specific JSON response content",
                      "pm.test(\"[POST]::/user/connect_account - Response contains is_email_sent\", function () {",
                      "  var jsonData = pm.response.json();",
                      "  pm.expect(jsonData).to.have.property(\"is_email_sent\");",
                      "  pm.expect(jsonData.is_email_sent).to.be.true;",
                      "});",
                      "",
                      ""
                    ],
                    "type": "text/javascript"
                  }
                },
                {
                  "listen": "prerequest",
                  "script": {
                    "exec": [
                      "",
                      "var baseEmail = pm.environment.get('user_base_email_for_signup');",
                      "var emailDomain = pm.environment.get(\"user_domain_for_signup\");",
                      "",
                      "// Generate a unique email address",
                      "var uniqueEmail = baseEmail + new Date().getTime() + emailDomain;",
                      "// Set the unique email address as an environment variable",
                      "pm.environment.set('unique_email', uniqueEmail);",
                      ""
                    ],
                    "type": "text/javascript"
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  },
                  {
                    "key": "Cookie",
                    "value": "Cookie_1=value"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\"email\":\"{{unique_email}}\"}"
                },
                "url": {
                  "raw": "{{baseUrl}}/user/connect_account",
                  "host": [
                    "{{baseUrl}}"
                  ],
                  "path": [
                    "user",
                    "connect_account"
                  ]
                }
              },
              "response": []
            }
          ]
        },
        {
          "name": "Sign In",
          "item": [
            {
              "name": "Signin",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "console.log(\"[LOG]::x-request-id - \" + pm.response.headers.get(\"x-request-id\"));",
                      "",
                      "// Validate status 2xx",
                      "pm.test(\"[POST]::/user/signin - Status code is 2xx\", function () {",
                      "  pm.response.to.be.success;",
                      "});",
                      "",
                      "// Validate if response header has matching content-type",
                      "pm.test(\"[POST]::/user/signin - Content-Type is application/json\", function () {",
                      "  pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(",
                      "    \"application/json\",",
                      "  );",
                      "});",
                      "",
                      "// Validate if response has JSON Body",
                      "pm.test(\"[POST]::/user/signin - Response has JSON Body\", function () {",
                      "  pm.response.to.have.jsonBody();",
                      "});",
                      "",
                      "// Validate specific JSON response content",
                      "pm.test(\"[POST]::/user/signin - Response contains token\", function () {",
                      "  var jsonData = pm.response.json();",
                      "  pm.expect(jsonData).to.have.property(\"token\");",
                      "  pm.expect(jsonData.token).to.be.a(\"string\").and.to.not.be.empty;",
                      "});"
                    ],
                    "type": "text/javascript"
                  }
                },
                {
                  "listen": "prerequest",
                  "script": {
                    "exec": [
                      ""
                    ],
                    "type": "text/javascript"
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  },
                  {
                    "key": "Cookie",
                    "value": "Cookie_1=value"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\"email\":\"{{user_email}}\",\"password\":\"{{user_password}}\"}"
                },
                "url": {
                  "raw": "{{baseUrl}}/user/signin",
                  "host": [
                    "{{baseUrl}}"
                  ],
                  "path": [
                    "user",
                    "signin"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "Signin Wrong",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "console.log(\"[LOG]::x-request-id - \" + pm.response.headers.get(\"x-request-id\"));",
                      "",
                      "// Validate status code is 4xx Bad Request",
                      "pm.test(\"[POST]::/user/signin - Status code is 401\", function () {",
                      "  pm.response.to.have.status(401);",
                      "});",
                      "",
                      "// Validate if response header has matching content-type",
                      "pm.test(\"[POST]::/user/signin - Content-Type is application/json\", function () {",
                      "  pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(",
                      "    \"application/json\",",
                      "  );",
                      "});",
                      "",
                      "// Validate if response has JSON Body",
                      "pm.test(\"[POST]::/user/signin - Response has JSON Body\", function () {",
                      "  pm.response.to.have.jsonBody();",
                      "});"
                    ],
                    "type": "text/javascript"
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  },
                  {
                    "key": "Cookie",
                    "value": "Cookie_1=value"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\"email\":\"{{user_email}}\",\"password\":\"{{wrong_password}}\"}"
                },
                "url": {
                  "raw": "{{baseUrl}}/user/signin",
                  "host": [
                    "{{baseUrl}}"
                  ],
                  "path": [
                    "user",
                    "signin"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "Signin V2 - To be deprecated",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "console.log(\"[LOG]::x-request-id - \" + pm.response.headers.get(\"x-request-id\"));",
                      "",
                      "// Validate status 2xx",
                      "pm.test(\"[POST]::user/v2/signin - Status code is 2xx\", function () {",
                      "  pm.response.to.be.success;",
                      "});",
                      "",
                      "// Validate if response header has matching content-type",
                      "pm.test(\"[POST]::user/v2/signin - Content-Type is application/json\", function () {",
                      "  pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(",
                      "    \"application/json\",",
                      "  );",
                      "});",
                      "",
                      "// Validate if response has JSON Body",
                      "pm.test(\"[POST]::user/v2/signin - Response has JSON Body\", function () {",
                      "  pm.response.to.have.jsonBody();",
                      "});",
                      "",
                      "// Validate specific JSON response content",
                      "pm.test(\"[POST]::user/v2/signin - Response contains token\", function () {",
                      "  var jsonData = pm.response.json();",
                      "  pm.expect(jsonData).to.have.property(\"token\");",
                      "  pm.expect(jsonData.token).to.be.a(\"string\").and.to.not.be.empty;",
                      "});"
                    ],
                    "type": "text/javascript"
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  },
                  {
                    "key": "Cookie",
                    "value": "Cookie_1=value"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\"email\":\"{{user_email}}\",\"password\":\"{{user_password}}\"}"
                },
                "url": {
                  "raw": "{{baseUrl}}/user/v2/signin",
                  "host": [
                    "{{baseUrl}}"
                  ],
                  "path": [
                    "user",
                    "v2",
                    "signin"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "Signin V2 Wrong",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "console.log(\"[LOG]::x-request-id - \" + pm.response.headers.get(\"x-request-id\"));",
                      "",
                      "// Validate status 4xx",
                      "pm.test(\"[POST]::/user/v2/signin - Status code is 401\", function () {",
                      "  pm.response.to.have.status(401);",
                      "});",
                      "",
                      "// Validate if response header has matching content-type",
                      "pm.test(\"[POST]::user/v2/signin - Content-Type is application/json\", function () {",
                      "  pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(",
                      "    \"application/json\",",
                      "  );",
                      "});",
                      "",
                      "// Validate if response has JSON Body",
                      "pm.test(\"[POST]::user/v2/signin - Response has JSON Body\", function () {",
                      "  pm.response.to.have.jsonBody();",
                      "});"
                    ],
                    "type": "text/javascript"
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  },
                  {
                    "key": "Cookie",
                    "value": "Cookie_1=value"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\"email\":\"{{user_email}}\",\"password\":\"{{wrong_password}}\"}"
                },
                "url": {
                  "raw": "{{baseUrl}}/user/v2/signin",
                  "host": [
                    "{{baseUrl}}"
                  ],
                  "path": [
                    "user",
                    "v2",
                    "signin"
                  ]
                }
              },
              "response": []
            }
          ]
        }
      ]
    }
  ],
  "info": {
    "_postman_id": "b5b40c9a-7e58-42c7-8b89-0adb208c45c9",
    "name": "users",
    "description": "## Get started\n\nJuspay Router provides a collection of APIs that enable you to process and manage payments. Our APIs accept and return JSON in the HTTP body, and return standard HTTP response codes.  \nYou can consume the APIs directly using your favorite HTTP/REST library.  \nWe have a testing environment referred to \"sandbox\", which you can setup to test API calls without affecting production data.\n\n### Base URLs\n\nUse the following base URLs when making requests to the APIs:\n\n| Environment | Base URL |\n| --- | --- |\n| Sandbox | [https://sandbox.hyperswitch.io](https://sandbox.hyperswitch.io) |\n| Production | [https://router.juspay.io](https://router.juspay.io) |\n\n# Authentication\n\nWhen you sign up for an account, you are given a secret key (also referred as api-key). You may authenticate all API requests with Juspay server by providing the appropriate key in the request Authorization header.  \nNever share your secret api keys. Keep them guarded and secure.\n\nContact Support:  \nName: Juspay Support  \nEmail: [support@juspay.in](mailto:support@juspay.in)",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "26710321"
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "",
      "type": "string"
    },
    {
      "key": "admin_api_key",
      "value": "",
      "type": "string"
    },
    {
      "key": "api_key",
      "value": "",
      "type": "string"
    },
    {
      "key": "merchant_id",
      "value": ""
    },
    {
      "key": "payment_id",
      "value": ""
    },
    {
      "key": "customer_id",
      "value": ""
    },
    {
      "key": "mandate_id",
      "value": ""
    },
    {
      "key": "payment_method_id",
      "value": ""
    },
    {
      "key": "refund_id",
      "value": ""
    },
    {
      "key": "merchant_connector_id",
      "value": ""
    },
    {
      "key": "client_secret",
      "value": "",
      "type": "string"
    },
    {
      "key": "connector_api_key",
      "value": "",
      "type": "string"
    },
    {
      "key": "publishable_key",
      "value": "",
      "type": "string"
    },
    {
      "key": "api_key_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "payment_token",
      "value": ""
    },
    {
      "key": "gateway_merchant_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "certificate",
      "value": "",
      "type": "string"
    },
    {
      "key": "certificate_keys",
      "value": "",
      "type": "string"
    },
    {
      "key": "connector_api_secret",
      "value": "",
      "type": "string"
    },
    {
      "key": "connector_key1",
      "value": "",
      "type": "string"
    },
    {
      "key": "connector_key2",
      "value": "",
      "type": "string"
    },
    {
      "key": "user_email",
      "value": "",
      "type": "string"
    },
    {
      "key": "user_password",
      "value": "",
      "type": "string"
    },
    {
      "key": "wrong_password",
      "value": "",
      "type": "string"
    },
    {
      "key": "user_base_email_for_signup",
      "value": "",
      "type": "string"
    },
    {
      "key": "user_domain_for_signup",
      "value": "",
      "type": "string"
    }
  ]
}