{
  "info": {
    "name": "PayQube API v1",
    "description": "Payments, refunds and sandbox payouts. Set the collection variables baseUrl, keyId and secret (from Dashboard → API keys). Auth is HTTP Basic: key ID as username, secret as password.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "basic",
    "basic": [
      { "key": "username", "value": "{{keyId}}", "type": "string" },
      { "key": "password", "value": "{{secret}}", "type": "string" }
    ]
  },
  "variable": [
    { "key": "baseUrl", "value": "https://your-payqube-domain" },
    { "key": "keyId", "value": "pq_test_xxxxxxxxxxxxxxxx" },
    { "key": "secret", "value": "sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" },
    { "key": "paymentId", "value": "" },
    { "key": "payoutId", "value": "" },
    { "key": "beneficiaryId", "value": "" }
  ],
  "item": [
    {
      "name": "Payments",
      "item": [
        {
          "name": "Create payment",
          "event": [{ "listen": "test", "script": { "type": "text/javascript", "exec": ["const j = pm.response.json(); if (j.id) pm.collectionVariables.set('paymentId', j.id);"] } }],
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": "{{baseUrl}}/api/v1/payments",
            "body": { "mode": "raw", "raw": "{\n  \"amount\": 499,\n  \"order_id\": \"ORD-{{$timestamp}}\",\n  \"description\": \"Order payment\",\n  \"return_url\": \"https://example.com/thanks\",\n  \"customer\": { \"name\": \"Asha Verma\", \"email\": \"asha@example.com\", \"phone\": \"9876543210\" }\n}" }
          }
        },
        { "name": "Fetch payment", "request": { "method": "GET", "url": "{{baseUrl}}/api/v1/payments/{{paymentId}}" } },
        { "name": "List payments", "request": { "method": "GET", "url": "{{baseUrl}}/api/v1/payments?limit=20" } },
        {
          "name": "Refund payment",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": "{{baseUrl}}/api/v1/payments/{{paymentId}}/refunds",
            "body": { "mode": "raw", "raw": "{ \"amount\": 100 }" }
          }
        }
      ]
    },
    {
      "name": "Payouts (sandbox)",
      "item": [
        { "name": "Balance", "request": { "method": "GET", "url": "{{baseUrl}}/api/v1/balance" } },
        {
          "name": "List beneficiaries",
          "event": [{ "listen": "test", "script": { "type": "text/javascript", "exec": ["const j = pm.response.json(); if (j.data && j.data[0]) pm.collectionVariables.set('beneficiaryId', j.data[0].id);"] } }],
          "request": { "method": "GET", "url": "{{baseUrl}}/api/v1/beneficiaries" }
        },
        {
          "name": "Create payout",
          "event": [{ "listen": "test", "script": { "type": "text/javascript", "exec": ["const j = pm.response.json(); if (j.id) pm.collectionVariables.set('payoutId', j.id);"] } }],
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": "{{baseUrl}}/api/v1/payouts",
            "body": { "mode": "raw", "raw": "{ \"beneficiary_id\": {{beneficiaryId}}, \"amount\": 250, \"method\": \"IMPS\", \"narration\": \"Vendor payment\" }" }
          }
        },
        { "name": "Fetch payout", "request": { "method": "GET", "url": "{{baseUrl}}/api/v1/payouts/{{payoutId}}" } },
        { "name": "List payouts", "request": { "method": "GET", "url": "{{baseUrl}}/api/v1/payouts" } }
      ]
    }
  ]
}
