{
  "info": {
    "_postman_id": "whish-pay-qr",
    "name": "Whish \u00b7 Whish Pay QR (v1.0.0)",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Whish Pay QR (itel-service). Creates a payment session that returns a QR payload and six-digit code the customer scans or enters to pay from their Whish balance. Set channel, secret and websiteUrl as collection variables (or use an environment). Create a payment session generates a unique externalId on every send; Get payment status reuses that same id, so run Create first. Reusing an externalId returns the existing active session instead of a new one. 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": "channel",
            "value": "{{channel}}"
          },
          {
            "key": "secret",
            "value": "{{secret}}"
          },
          {
            "key": "websiteUrl",
            "value": "{{websiteUrl}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/payment/account/balance?currency=USD",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "payment",
            "account",
            "balance"
          ],
          "query": [
            {
              "key": "currency",
              "value": "USD"
            }
          ]
        }
      }
    },
    {
      "name": "Create a payment session",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "channel",
            "value": "{{channel}}"
          },
          {
            "key": "secret",
            "value": "{{secret}}"
          },
          {
            "key": "websiteUrl",
            "value": "{{websiteUrl}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/payment/whish/session",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "payment",
            "whish",
            "session"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"amount\": 10.0,\n  \"currency\": \"USD\",\n  \"externalId\": \"{{externalId}}\",\n  \"invoice\": \"INV-2026-0001\",\n  \"callbackUrl\": \"https://merchant.example/api/whish/payment-success?orderId=ORDER-2026-0001\",\n  \"expiry\": 10\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'));"
            ]
          }
        }
      ]
    },
    {
      "name": "Get payment status",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "channel",
            "value": "{{channel}}"
          },
          {
            "key": "secret",
            "value": "{{secret}}"
          },
          {
            "key": "websiteUrl",
            "value": "{{websiteUrl}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/payment/collect/status",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "payment",
            "collect",
            "status"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"currency\": \"USD\",\n  \"externalId\": \"{{externalId}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      }
    }
  ],
  "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": "channel",
      "value": "",
      "description": "Your channel id, issued by Whish Money. Replace this before sending."
    },
    {
      "key": "secret",
      "value": "",
      "description": "Your secret, issued by Whish Money. Replace this before sending."
    },
    {
      "key": "websiteUrl",
      "value": "",
      "description": "The website URL registered with your Whish Money account. Replace this before sending."
    },
    {
      "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."
    }
  ]
}