{
  "info": {
    "_postman_id": "whish-direct-credit",
    "name": "Whish \u00b7 Direct Credit (v1.0.0)",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Direct Credit (W2W) API (itel-service). Set channel, secret and websiteUrl as collection variables. Note: sendw2w requires IP whitelisting of your egress IPs. Send a whish-to-whish credit generates a unique externalId on every send; Get credit status reuses that same id, so run Send first. Never reuse an externalId for a new credit: the API would replay the original result instead of crediting again. 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": "Send a whish-to-whish credit",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "channel",
            "value": "{{channel}}"
          },
          {
            "key": "secret",
            "value": "{{secret}}"
          },
          {
            "key": "websiteUrl",
            "value": "{{websiteUrl}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/payment/sendw2w",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "payment",
            "sendw2w"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"externalId\": \"{{externalId}}\",\n  \"note\": \"Payout for order #A-1234\",\n  \"countryCode\": \"961\",\n  \"msisdn\": \"+9617XXXXXXX\",\n  \"amount\": 50.0,\n  \"currency\": \"USD\"\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 credit status",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "channel",
            "value": "{{channel}}"
          },
          {
            "key": "secret",
            "value": "{{secret}}"
          },
          {
            "key": "websiteUrl",
            "value": "{{websiteUrl}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/payment/sendw2w/status?externalId={{externalId}}&currency=USD",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "payment",
            "sendw2w",
            "status"
          ],
          "query": [
            {
              "key": "externalId",
              "value": "{{externalId}}"
            },
            {
              "key": "currency",
              "value": "USD"
            }
          ]
        }
      }
    }
  ],
  "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."
    }
  ]
}