{
  "info": {
    "name": "Kodano API Pública — Sandbox",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Rode primeiro '1. Obter access token'. O token fica em {{access_token}} e vale cerca de 12 horas. Preencha o ambiente com os dados da sua credencial."
  },
  "item": [
    {
      "name": "1. Obter access token",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('token emitido', () => pm.response.to.have.status(200));",
              "const j = pm.response.json();",
              "pm.environment.set('access_token', j.access_token);"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "auth": {
          "type": "basic",
          "basic": [
            {
              "key": "username",
              "value": "{{client_id}}",
              "type": "string"
            },
            {
              "key": "password",
              "value": "{{client_secret}}",
              "type": "string"
            }
          ]
        },
        "header": [
          {
            "key": "Content-Type",
            "value": "application/x-www-form-urlencoded"
          }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            {
              "key": "grant_type",
              "value": "client_credentials"
            },
            {
              "key": "scope",
              "value": "{{scope}}"
            }
          ]
        },
        "url": {
          "raw": "{{token_url}}",
          "host": [
            "{{token_url}}"
          ]
        }
      }
    },
    {
      "name": "2. Pagamentos",
      "item": [
        {
          "name": "Listar pagamentos",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              },
              {
                "key": "X-Merchant-Id",
                "value": "{{merchant_id}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/v1/payments?limit=5",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments"
              ],
              "query": [
                {
                  "key": "limit",
                  "value": "5"
                }
              ]
            }
          }
        },
        {
          "name": "Criar cobrança Pix",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              },
              {
                "key": "X-Merchant-Id",
                "value": "{{merchant_id}}"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/v1/payments/pix",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments",
                "pix"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"amount\": 1000,\n  \"currency\": \"BRL\",\n  \"description\": \"Cobrança de teste no sandbox\",\n  \"customer\": {\n    \"name\": \"Cliente Teste\",\n    \"document\": \"12345678909\",\n    \"email\": \"teste@example.com\"\n  },\n  \"expiresIn\": 3600,\n  \"metadata\": {\n    \"origem\": \"postman\"\n  }\n}"
            }
          }
        },
        {
          "name": "Consultar pagamento",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              },
              {
                "key": "X-Merchant-Id",
                "value": "{{merchant_id}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/v1/payments/{{payment_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments",
                "{{payment_id}}"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "3. Links de pagamento",
      "item": [
        {
          "name": "Listar links",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              },
              {
                "key": "X-Merchant-Id",
                "value": "{{merchant_id}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/v1/payment-links?limit=5",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payment-links"
              ],
              "query": [
                {
                  "key": "limit",
                  "value": "5"
                }
              ]
            }
          }
        }
      ]
    },
    {
      "name": "4. Clientes",
      "item": [
        {
          "name": "Listar clientes",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              },
              {
                "key": "X-Merchant-Id",
                "value": "{{merchant_id}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/v1/customers?limit=5",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "customers"
              ],
              "query": [
                {
                  "key": "limit",
                  "value": "5"
                }
              ]
            }
          }
        }
      ]
    },
    {
      "name": "5. Cartões",
      "item": [
        {
          "name": "Listar cartões do cliente",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              },
              {
                "key": "X-Merchant-Id",
                "value": "{{merchant_id}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/v1/cards?customerId={{customer_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "cards"
              ],
              "query": [
                {
                  "key": "customerId",
                  "value": "{{customer_id}}"
                }
              ]
            }
          }
        }
      ]
    },
    {
      "name": "6. Recebimentos",
      "item": [
        {
          "name": "Consultar saldo",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              },
              {
                "key": "X-Merchant-Id",
                "value": "{{merchant_id}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/v1/balance",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "balance"
              ]
            }
          }
        },
        {
          "name": "Consultar extrato",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{access_token}}"
              },
              {
                "key": "X-Merchant-Id",
                "value": "{{merchant_id}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/v1/statement?from={{statement_from}}&to={{statement_to}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "statement"
              ],
              "query": [
                {
                  "key": "from",
                  "value": "{{statement_from}}"
                },
                {
                  "key": "to",
                  "value": "{{statement_to}}"
                }
              ]
            }
          }
        }
      ]
    }
  ]
}