{
  "info": {
    "name": "SAVI Platform Integration",
    "description": "Partner integration collection for the SAVI Platform API (API-key routes). Set api_base_url to https://api.savi.sa and secret_key to your sk_test_ key. Run Integration → Ping first — it stores platform_id from the response.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "api_base_url",
      "value": "https://api.savi.sa"
    },
    {
      "key": "secret_key",
      "value": "sk_test_YOUR_KEY"
    },
    {
      "key": "platform_id",
      "value": ""
    },
    {
      "key": "merchant_id",
      "value": ""
    },
    {
      "key": "payment_id",
      "value": ""
    }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{secret_key}}", "type": "string" }]
  },
  "item": [
    {
      "name": "Integration",
      "item": [
        {
          "name": "Ping",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.platformId) pm.collectionVariables.set('platform_id', json.platformId);"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{api_base_url}}/v1/integration/ping"
          }
        }
      ]
    },
    {
      "name": "Merchants",
      "item": [
        {
          "name": "Create merchant",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.id) pm.collectionVariables.set('merchant_id', json.id);"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"externalId\": \"postman-seller-001\",\n  \"businessName\": \"Postman Test Shop\",\n  \"contactEmail\": \"seller@example.com\",\n  \"verificationPath\": \"platform\"\n}"
            },
            "url": "{{api_base_url}}/v1/merchants"
          }
        },
        {
          "name": "Add bank account",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"iban\": \"SA0380000000608010167519\",\n  \"accountHolderName\": \"Test Seller\"\n}"
            },
            "url": "{{api_base_url}}/v1/merchants/{{merchant_id}}/bank-account"
          }
        }
      ]
    },
    {
      "name": "KYC",
      "item": [
        {
          "name": "Submit attestation (Path 1)",
          "request": {
            "method": "PUT",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"verified\": true,\n  \"verifiedAt\": \"2026-06-12T10:00:00.000Z\",\n  \"method\": \"platform_kyc\",\n  \"externalRef\": \"KYC-POSTMAN-001\"\n}"
            },
            "url": "{{api_base_url}}/v1/merchants/{{merchant_id}}/kyc/attestation"
          }
        },
        {
          "name": "Get KYC status",
          "request": {
            "method": "GET",
            "url": "{{api_base_url}}/v1/merchants/{{merchant_id}}/kyc/status"
          }
        }
      ]
    },
    {
      "name": "Payments",
      "item": [
        {
          "name": "Create payment",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.id) pm.collectionVariables.set('payment_id', json.id);"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"merchantId\": \"{{merchant_id}}\",\n  \"amountHalalas\": 15000,\n  \"description\": \"Postman test order\",\n  \"externalOrderId\": \"ORD-POSTMAN-001\"\n}"
            },
            "url": "{{api_base_url}}/v1/payments"
          }
        },
        {
          "name": "Get payment",
          "request": {
            "method": "GET",
            "url": "{{api_base_url}}/v1/payments/{{payment_id}}"
          }
        }
      ]
    },
    {
      "name": "Payouts",
      "item": [
        {
          "name": "Get merchant balance",
          "request": {
            "method": "GET",
            "url": "{{api_base_url}}/v1/merchants/{{merchant_id}}/balance"
          }
        }
      ]
    }
  ]
}
