{
  "info": {
    "_postman_id": "whish-international-topup",
    "name": "Whish \u00b7 International Topup (v1.0.0)",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "International Topup (Third Party V2) API (itel-service). Set sessionId, token and provider as collection variables. {{provider}} is the provider code Whish gives you (for example etisalatNba). Pay for a top-up generates a unique externalId on every send. Never reuse one for a new payment: the API would replay the original result. Note: the reference page marks User-Agent required and your integration must send it. This collection deliberately omits it because Postman always sends its own User-Agent and would override the value anyway."
  },
  "item": [
    {
      "name": "Get account balance",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "sessionId",
            "value": "{{sessionId}}"
          },
          {
            "key": "token",
            "value": "{{token}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/account/balance",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "account",
            "balance"
          ]
        }
      }
    },
    {
      "name": "List top-up options",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "sessionId",
            "value": "{{sessionId}}"
          },
          {
            "key": "token",
            "value": "{{token}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v2/{{provider}}/fetch",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "{{provider}}",
            "fetch"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"target\": \"+971561234567\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      }
    },
    {
      "name": "Pay for a top-up",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "sessionId",
            "value": "{{sessionId}}"
          },
          {
            "key": "token",
            "value": "{{token}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v2/{{provider}}/pay",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "{{provider}}",
            "pay"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"target\": \"+971561234567\",\n  \"optionId\": \"341504052\",\n  \"amount\": 10.0,\n  \"externalId\": \"{{externalId}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "type": "text/javascript",
            "exec": [
              "// externalId must be UNIQUE per transaction. Reusing one replays the original",
              "// result instead of creating a new transaction.",
              "// Millisecond clock + a monotonic counter: Date.now() alone repeats when the Collection",
              "// Runner fires several requests inside the same millisecond, so the counter guarantees",
              "// each send differs. Digits only, and the body quotes it because externalId is a String.",
              "var seq = (parseInt(pm.collectionVariables.get('_seq'), 10) || 0) + 1;",
              "pm.collectionVariables.set('_seq', seq);",
              "pm.collectionVariables.set('externalId', String(Date.now()) + String(seq % 10000).padStart(4, '0'));"
            ]
          }
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://partner.api.sbx.whish.money/itel-service/api",
      "description": "Base URL for this environment. Correct as shipped; attach an environment to switch."
    },
    {
      "key": "sessionId",
      "value": "",
      "description": "Your session id, issued by Whish Money. Replace this before sending."
    },
    {
      "key": "token",
      "value": "",
      "description": "Your token, issued by Whish Money. Replace this before sending."
    },
    {
      "key": "provider",
      "value": "etisalatNba",
      "description": "Provider code Whish Money gives you, for example etisalatNba."
    },
    {
      "key": "externalId",
      "value": "",
      "description": "Set automatically before every send by the pre-request script, and must be unique per transaction. Leave this empty."
    },
    {
      "key": "_seq",
      "value": "",
      "description": "Internal counter used by the pre-request script to keep generated ids unique. Leave this empty."
    }
  ]
}