{
  "info": {
    "name": "Bank Sandbox API (PSP Simulator)",
    "_postman_id": "c0928b58-a61b-44c1-a466-6e9fec04dc98",
    "description": "Postman collection for the Bank PSP Sandbox API flow (authorize/capture/refund/3DS/webhooks). Variables: base_url, api_key, merchant_order_id, amount, currency, encrypted_card_payload, webhook_url, return_url, transaction_id.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://banksandboxapi.shake-out.com"
    },
    {
      "key": "local_base_url",
      "value": "https://banksandboxapi.test"
    },
    {
      "key": "production_base_url",
      "value": "https://banksandboxapi.shake-out.com"
    },
    {
      "key": "api_key",
      "value": ""
    },
    {
      "key": "merchant_order_id",
      "value": "ORD-POSTMAN-001"
    },
    {
      "key": "amount",
      "value": "100.50"
    },
    {
      "key": "currency",
      "value": "EGP"
    },
    {
      "key": "encrypted_card_payload",
      "value": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
    },
    {
      "key": "webhook_url",
      "value": "https://example.com/webhook"
    },
    {
      "key": "return_url",
      "value": "https://merchant.test/return"
    },
    {
      "key": "transaction_id",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "Health",
      "item": [
        {
          "name": "GET /api/health",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{base_url}}/api/health"
          }
        }
      ]
    },
    {
      "name": "Payments",
      "item": [
        {
          "name": "POST /api/psp/payments/authorize (approve)",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 200) {",
                  "  const json = pm.response.json();",
                  "  if (json.transaction_id) pm.collectionVariables.set('transaction_id', json.transaction_id);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Api-Key",
                "value": "{{api_key}}"
              },
              {
                "key": "Idempotency-Key",
                "value": "idem-{{merchant_order_id}}-approve",
                "disabled": true
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"merchant_order_id\": \"{{merchant_order_id}}\",\n  \"amount\": \"{{amount}}\",\n  \"currency\": \"{{currency}}\",\n  \"encrypted_card_payload\": \"{{encrypted_card_payload}}\",\n  \"scenario\": \"approve\",\n  \"webhook_url\": \"{{webhook_url}}\",\n  \"return_url\": \"{{return_url}}\"\n}"
            },
            "url": "{{base_url}}/api/psp/payments/authorize"
          }
        },
        {
          "name": "POST /api/psp/payments/authorize (decline)",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 200) {",
                  "  const json = pm.response.json();",
                  "  if (json.transaction_id) pm.collectionVariables.set('transaction_id', json.transaction_id);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Api-Key",
                "value": "{{api_key}}"
              },
              {
                "key": "Idempotency-Key",
                "value": "idem-{{merchant_order_id}}-decline",
                "disabled": true
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"merchant_order_id\": \"{{merchant_order_id}}\",\n  \"amount\": \"{{amount}}\",\n  \"currency\": \"{{currency}}\",\n  \"encrypted_card_payload\": \"{{encrypted_card_payload}}\",\n  \"scenario\": \"decline\",\n  \"webhook_url\": \"{{webhook_url}}\",\n  \"return_url\": \"{{return_url}}\"\n}"
            },
            "url": "{{base_url}}/api/psp/payments/authorize"
          }
        },
        {
          "name": "POST /api/psp/payments/authorize (3ds)",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 200) {",
                  "  const json = pm.response.json();",
                  "  if (json.transaction_id) pm.collectionVariables.set('transaction_id', json.transaction_id);",
                  "  if (json.acs_url) pm.collectionVariables.set('acs_url', json.acs_url);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Api-Key",
                "value": "{{api_key}}"
              },
              {
                "key": "Idempotency-Key",
                "value": "idem-{{merchant_order_id}}-3ds",
                "disabled": true
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"merchant_order_id\": \"{{merchant_order_id}}\",\n  \"amount\": \"{{amount}}\",\n  \"currency\": \"{{currency}}\",\n  \"encrypted_card_payload\": \"{{encrypted_card_payload}}\",\n  \"scenario\": \"3ds\",\n  \"webhook_url\": \"{{webhook_url}}\",\n  \"return_url\": \"{{return_url}}\"\n}"
            },
            "url": "{{base_url}}/api/psp/payments/authorize"
          }
        },
        {
          "name": "POST /api/psp/payments/authorize (timeout)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Api-Key",
                "value": "{{api_key}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"merchant_order_id\": \"{{merchant_order_id}}\",\n  \"amount\": \"{{amount}}\",\n  \"currency\": \"{{currency}}\",\n  \"encrypted_card_payload\": \"{{encrypted_card_payload}}\",\n  \"scenario\": \"timeout\",\n  \"webhook_url\": \"{{webhook_url}}\",\n  \"return_url\": \"{{return_url}}\"\n}"
            },
            "url": "{{base_url}}/api/psp/payments/authorize"
          }
        },
        {
          "name": "POST /api/psp/payments/authorize (error)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Api-Key",
                "value": "{{api_key}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"merchant_order_id\": \"{{merchant_order_id}}\",\n  \"amount\": \"{{amount}}\",\n  \"currency\": \"{{currency}}\",\n  \"encrypted_card_payload\": \"{{encrypted_card_payload}}\",\n  \"scenario\": \"error\",\n  \"webhook_url\": \"{{webhook_url}}\",\n  \"return_url\": \"{{return_url}}\"\n}"
            },
            "url": "{{base_url}}/api/psp/payments/authorize"
          }
        },
        {
          "name": "POST /api/psp/payments/capture",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Api-Key",
                "value": "{{api_key}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"transaction_id\": \"{{transaction_id}}\"\n}"
            },
            "url": "{{base_url}}/api/psp/payments/capture"
          }
        },
        {
          "name": "POST /api/psp/payments/refund",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Api-Key",
                "value": "{{api_key}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"transaction_id\": \"{{transaction_id}}\"\n}"
            },
            "url": "{{base_url}}/api/psp/payments/refund"
          }
        }
      ]
    },
    {
      "name": "3DS",
      "item": [
        {
          "name": "GET /api/psp/3ds/challenge/{{transaction_id}} (browser page)",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{base_url}}/api/psp/3ds/challenge/{{transaction_id}}"
          }
        },
        {
          "name": "POST /api/psp/3ds/complete/{{transaction_id}} (JSON)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Api-Key",
                "value": "{{api_key}}",
                "disabled": true
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"result\": \"success\"\n}"
            },
            "url": "{{base_url}}/api/psp/3ds/complete/{{transaction_id}}"
          }
        },
        {
          "name": "POST /api/psp/3ds/complete/{{transaction_id}} (form-urlencoded)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/x-www-form-urlencoded"
              }
            ],
            "body": {
              "mode": "urlencoded",
              "urlencoded": [
                {
                  "key": "result",
                  "value": "success"
                },
                {
                  "key": "otp",
                  "value": "123456",
                  "disabled": true
                }
              ]
            },
            "url": "{{base_url}}/api/psp/3ds/complete/{{transaction_id}}"
          }
        }
      ]
    },
    {
      "name": "Transactions",
      "item": [
        {
          "name": "GET /api/psp/transactions/{{transaction_id}}",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "X-Api-Key",
                "value": "{{api_key}}"
              }
            ],
            "url": "{{base_url}}/api/psp/transactions/{{transaction_id}}"
          }
        }
      ]
    }
  ]
}