{
  "info": {
    "name": "ZiniPay Transaction Verification API",
    "description": "Advanced two-step transaction verification — Verify then Confirm",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://api.zinipay.com/v1/trx",
      "type": "string"
    },
    {
      "key": "api_key",
      "value": "your_brand_api_key_here",
      "type": "string"
    },
    {
      "key": "transaction_id",
      "value": "TXN123456789",
      "type": "string",
      "description": "The transaction ID to verify"
    },
    {
      "key": "amount",
      "value": "500",
      "type": "string"
    },
    {
      "key": "verified_id",
      "value": "",
      "type": "string",
      "description": "Auto-filled from Verify response (data.id) — used in Confirm"
    },
    {
      "key": "verified_trx_id",
      "value": "",
      "type": "string",
      "description": "Auto-filled from Verify response (data.trxID) — used in Confirm"
    }
  ],
  "item": [
    {
      "name": "Step 1 — Verify Transaction (by transactionId)",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "const res = pm.response.json();",
              "if (res.success && res.data) {",
              "  pm.collectionVariables.set('verified_id', res.data.id);",
              "  pm.collectionVariables.set('verified_trx_id', res.data.trxID);",
              "  console.log('verified_id:', res.data.id);",
              "  console.log('verified_trx_id:', res.data.trxID);",
              "}",
              "pm.test('Success true', () => pm.expect(res.success).to.be.true);",
              "pm.test('Status UNUSED', () => pm.expect(res.data.status).to.eql('UNUSED'));",
              "pm.test('Has internal id', () => pm.expect(res.data.id).to.be.a('number'));"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "zinipay-api-key", "value": "{{api_key}}" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"transactionId\": \"{{transaction_id}}\",\n  \"amount\": {{amount}}\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": {
          "raw": "{{base_url}}/verify",
          "host": ["{{base_url}}"],
          "path": ["verify"]
        },
        "description": "Verifies transaction by transactionId. Deducts 1 credit. Auto-saves data.id → {{verified_id}} and data.trxID → {{verified_trx_id}} for use in Confirm."
      },
      "response": [
        {
          "name": "Success",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"statusCode\": 200,\n  \"success\": true,\n  \"message\": \"Transaction verified successfully.\",\n  \"data\": {\n    \"id\": 1234,\n    \"trxID\": \"TXN123456789\",\n    \"smsRef\": \"ORDER-1001\",\n    \"amount\": 500,\n    \"sender\": \"017****5678\",\n    \"status\": \"UNUSED\",\n    \"provider\": \"bKash\",\n    \"timestamp\": \"2026-05-20T10:30:00.000Z\"\n  }\n}"
        }
      ]
    },
    {
      "name": "Step 1 (alt) — Verify Transaction (by smsRef)",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "const res = pm.response.json();",
              "if (res.success && res.data) {",
              "  pm.collectionVariables.set('verified_id', res.data.id);",
              "  pm.collectionVariables.set('verified_trx_id', res.data.trxID);",
              "  console.log('verified_id:', res.data.id);",
              "  console.log('verified_trx_id:', res.data.trxID);",
              "}",
              "pm.test('Success true', () => pm.expect(res.success).to.be.true);",
              "pm.test('Status UNUSED', () => pm.expect(res.data.status).to.eql('UNUSED'));",
              "pm.test('Has internal id', () => pm.expect(res.data.id).to.be.a('number'));"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "zinipay-api-key", "value": "{{api_key}}" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"smsRef\": \"ORDER-1001\",\n  \"amount\": {{amount}}\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": {
          "raw": "{{base_url}}/verify",
          "host": ["{{base_url}}"],
          "path": ["verify"]
        },
        "description": "Alternative verify using smsRef (customer payment reference) instead of transactionId."
      },
      "response": []
    },
    {
      "name": "Step 2 — Confirm Transaction",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "const res = pm.response.json();",
              "pm.test('Success true', () => pm.expect(res.success).to.be.true);",
              "pm.test('Status consumed (false)', () => pm.expect(res.data.status).to.be.false);",
              "pm.test('Has transactionId', () => pm.expect(res.data.transactionId).to.be.a('string'));",
              "pm.test('Has senderNumber', () => pm.expect(res.data.senderNumber).to.be.a('string'));"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "zinipay-api-key", "value": "{{api_key}}" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"transactionId\": \"{{verified_trx_id}}\",\n  \"amount\": {{amount}},\n  \"id\": {{verified_id}}\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": {
          "raw": "{{base_url}}/confirm",
          "host": ["{{base_url}}"],
          "path": ["confirm"]
        },
        "description": "⚠️ IRREVERSIBLE — Permanently consumes the transaction. Uses {{verified_trx_id}} and {{verified_id}} auto-set by Step 1. Run Step 1 first."
      },
      "response": [
        {
          "name": "Success",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"statusCode\": 200,\n  \"success\": true,\n  \"message\": \"Transaction confirmed and successfully consumed.\",\n  \"data\": {\n    \"id\": 1234,\n    \"provider\": \"bKash\",\n    \"message\": \"Payment received...\",\n    \"transactionId\": \"TXN123456789\",\n    \"senderNumber\": \"01712345678\",\n    \"amount\": 500,\n    \"timestamp\": \"2026-05-20T10:30:00.000Z\",\n    \"status\": false\n  }\n}"
        }
      ]
    }
  ]
}
