{
  "info": {
    "name": "SMG Pay — Merchant API",
    "description": "Social Media Guru merchant payments. Set `secret` to your sk_live_ key from Merchant → API keys.\n\nDocs: https://www.socialmediaguru.co.za/developers",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl", "value": "https://www.socialmediaguru.co.za" },
    { "key": "secret", "value": "sk_live_YOUR_SECRET" },
    { "key": "paymentId", "value": "" }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{secret}}", "type": "string" }]
  },
  "item": [
    {
      "name": "Create payment",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const json = pm.response.json();",
              "if (json && json.data && json.data.id) {",
              "  pm.collectionVariables.set('paymentId', json.data.id);",
              "}"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "url": "{{baseUrl}}/api/v1/payments",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"amount\": 199.00,\n  \"merchant_ref\": \"ORD-{{$timestamp}}\",\n  \"customer\": {\n    \"name\": \"Jane Doe\",\n    \"email\": \"jane@example.com\",\n    \"phone\": \"0713743360\"\n  },\n  \"return_url\": \"https://yourstore.co.za/thanks\",\n  \"cancel_url\": \"https://yourstore.co.za/cancel\"\n}"
        }
      }
    },
    {
      "name": "List payments",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{baseUrl}}/api/v1/payments?limit=25",
          "host": ["{{baseUrl}}"],
          "path": ["api", "v1", "payments"],
          "query": [
            { "key": "status", "value": "paid", "disabled": true },
            { "key": "limit", "value": "25" }
          ]
        }
      }
    },
    {
      "name": "Retrieve payment",
      "request": {
        "method": "GET",
        "url": "{{baseUrl}}/api/v1/payments/{{paymentId}}"
      }
    },
    {
      "name": "Cancel pending payment",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "url": "{{baseUrl}}/api/v1/payments/{{paymentId}}",
        "body": {
          "mode": "raw",
          "raw": "{ \"action\": \"cancel\" }"
        }
      }
    },
    {
      "name": "Balance",
      "request": {
        "method": "GET",
        "url": "{{baseUrl}}/api/v1/balance"
      }
    }
  ]
}
