{
  "info": {
    "name": "PEWANG M-Pesa Partner API",
    "_postman_id": "61ff6aa4-8f5d-4d20-8f14-59db8f8d2a7e",
    "description": "Collection for banks/loan systems integrating WhatsApp + M-Pesa payment flows.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl", "value": "https://gateway.pewang.company" },
    { "key": "apiKey", "value": "sk_live_replace_me" },
    { "key": "bearerToken", "value": "replace_user_session_token" },
    { "key": "checkoutRequestId", "value": "ws_CO_replace_after_stk_push" },
    { "key": "idempotencyKey", "value": "replace-with-uuid-per-request" },
    { "key": "reToken", "value": "A1B2C3D4" },
    { "key": "fromIso", "value": "2026-04-01T00:00:00.000Z" },
    { "key": "toIso", "value": "2026-04-30T23:59:59.999Z" },
    { "key": "webhookUrl", "value": "https://partner.example.com/hooks/pewang" },
    { "key": "webhookSecret", "value": "replace_with_shared_secret" }
  ],
  "item": [
    {
      "name": "1. STK Push",
      "request": {
        "method": "POST",
        "header": [
          { "key": "x-api-key", "value": "{{apiKey}}" },
          { "key": "Idempotency-Key", "value": "{{idempotencyKey}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"phone\": \"254712345678\",\n  \"amountKes\": 1500,\n  \"accountReference\": \"LOAN-2026-001\",\n  \"transactionDesc\": \"LoanInstallment\",\n  \"clientId\": \"bank_collection_bot\"\n}"
        },
        "url": { "raw": "{{baseUrl}}/api/mpesa/stk-push", "host": ["{{baseUrl}}"], "path": ["api", "mpesa", "stk-push"] }
      }
    },
    {
      "name": "2. STK Status",
      "request": {
        "method": "GET",
        "header": [{ "key": "x-api-key", "value": "{{apiKey}}" }],
        "url": {
          "raw": "{{baseUrl}}/api/mpesa/stk-status/{{checkoutRequestId}}",
          "host": ["{{baseUrl}}"],
          "path": ["api", "mpesa", "stk-status", "{{checkoutRequestId}}"]
        }
      }
    },
    {
      "name": "3. Redeem RE Token",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Idempotency-Key", "value": "{{idempotencyKey}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"token\": \"{{reToken}}\"\n}"
        },
        "url": { "raw": "{{baseUrl}}/api/mpesa/redeem-re", "host": ["{{baseUrl}}"], "path": ["api", "mpesa", "redeem-re"] }
      }
    },
    {
      "name": "4. List Transactions (Reconciliation)",
      "request": {
        "method": "GET",
        "header": [{ "key": "x-api-key", "value": "{{apiKey}}" }],
        "url": {
          "raw": "{{baseUrl}}/api/mpesa/transactions?from={{fromIso}}&to={{toIso}}&status=success&limit=100",
          "host": ["{{baseUrl}}"],
          "path": ["api", "mpesa", "transactions"],
          "query": [
            { "key": "from", "value": "{{fromIso}}" },
            { "key": "to", "value": "{{toIso}}" },
            { "key": "status", "value": "success" },
            { "key": "limit", "value": "100" }
          ]
        }
      }
    },
    {
      "name": "5. Reconciliation Summary",
      "request": {
        "method": "GET",
        "header": [{ "key": "x-api-key", "value": "{{apiKey}}" }],
        "url": {
          "raw": "{{baseUrl}}/api/mpesa/reconciliation/summary?from={{fromIso}}&to={{toIso}}",
          "host": ["{{baseUrl}}"],
          "path": ["api", "mpesa", "reconciliation", "summary"],
          "query": [
            { "key": "from", "value": "{{fromIso}}" },
            { "key": "to", "value": "{{toIso}}" }
          ]
        }
      }
    },
    {
      "name": "6. Download Receipt PDF",
      "request": {
        "method": "GET",
        "header": [{ "key": "x-api-key", "value": "{{apiKey}}" }],
        "url": {
          "raw": "{{baseUrl}}/api/mpesa/receipt/{{checkoutRequestId}}",
          "host": ["{{baseUrl}}"],
          "path": ["api", "mpesa", "receipt", "{{checkoutRequestId}}"]
        }
      }
    },
    {
      "name": "7. Configure Webhook URL + Secret",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Authorization", "value": "Bearer {{bearerToken}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"url\": \"{{webhookUrl}}\",\n  \"secret\": \"{{webhookSecret}}\"\n}"
        },
        "url": { "raw": "{{baseUrl}}/api/user/webhook", "host": ["{{baseUrl}}"], "path": ["api", "user", "webhook"] }
      }
    }
  ]
}
