{
  "info": {
    "name": "Openpay Paynet Water API - Integradores ERP",
    "description": "Coleccion publica para sistemas comerciales. Usa x-api-key e Idempotency-Key. Genera Paynet/Openpay, BBVA, Banco Azteca y Santander con external_id, expiration_date y providers. No enviar base_reference ni free_digit; las referencias bancarias locales las calcula la API. Openpay usa payment_order_id tecnico como order_id.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://pagos-op.aiscomds.com.mx"
    },
    {
      "key": "apiKey",
      "value": "TU_API_KEY"
    },
    {
      "key": "idempotencyKey",
      "value": "RECIBO-2026-TEST-000001"
    },
    {
      "key": "paymentOrderId",
      "value": "payord_xxx"
    },
    {
      "key": "externalId",
      "value": "RECIBO-2026-000001"
    },
    {
      "key": "batchId",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "Operations",
      "item": [
        {
          "name": "Health",
          "request": {
            "method": "GET",
            "url": "{{baseUrl}}/api/v1/health"
          }
        },
        {
          "name": "Version",
          "request": {
            "method": "GET",
            "url": "{{baseUrl}}/api/v1/version"
          }
        },
        {
          "name": "OpenAPI 3.1",
          "request": {
            "method": "GET",
            "url": "{{baseUrl}}/docs/openapi.json"
          }
        }
      ]
    },
    {
      "name": "Payment References",
      "item": [
        {
          "name": "Crear referencia Paynet + BBVA + Banco Azteca + Santander",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{idempotencyKey}}"
              }
            ],
            "url": "{{baseUrl}}/api/v1/payment-references",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"external_id\": \"RECIBO-2026-000001\",\n  \"customer_id\": \"CONTRATO-123456\",\n  \"amount\": 248.5,\n  \"description\": \"Pago de agua potable junio 2026\",\n  \"expiration_date\": \"2026-07-31\",\n  \"providers\": [\n    \"openpay\",\n    \"bbva\",\n    \"banco_azteca\",\n    \"santander\"\n  ],\n  \"metadata\": {\n    \"contract_id\": \"CONTRATO-123456\",\n    \"customer_name\": \"Juan Perez\",\n    \"customer_email\": \"juan@example.com\",\n    \"customer_phone\": \"5555555555\",\n    \"period\": \"2026-06\"\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "Para cada recibo nuevo cambia external_id e Idempotency-Key. No envies base_reference ni free_digit."
          }
        },
        {
          "name": "Consultar por payment_order_id",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "x-api-key",
                "value": "{{apiKey}}"
              }
            ],
            "url": "{{baseUrl}}/api/v1/payment-references/{{paymentOrderId}}"
          }
        },
        {
          "name": "Consultar por external_id",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "x-api-key",
                "value": "{{apiKey}}"
              }
            ],
            "url": "{{baseUrl}}/api/v1/payment-references/by-external/{{externalId}}"
          }
        }
      ]
    },
    {
      "name": "Batches",
      "item": [
        {
          "name": "Crear lote JSON multiproveedor",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Idempotency-Key",
                "value": "BATCH-2026-TEST-000001"
              }
            ],
            "url": "{{baseUrl}}/api/v1/payment-references/batches",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"batch_external_id\": \"LOTE-2026-07\",\n  \"providers\": [\n    \"openpay\",\n    \"bbva\",\n    \"banco_azteca\",\n    \"santander\"\n  ],\n  \"items\": [\n    {\n      \"external_id\": \"RECIBO-2026-000001\",\n      \"customer_id\": \"CONTRATO-123456\",\n      \"amount\": 248.5,\n      \"description\": \"Pago de agua potable junio 2026\",\n      \"expiration_date\": \"2026-07-31\",\n      \"metadata\": {\n        \"contract_id\": \"CONTRATO-123456\",\n        \"customer_name\": \"Juan Perez\",\n        \"customer_email\": \"juan@example.com\",\n        \"customer_phone\": \"5555555555\",\n        \"period\": \"2026-06\"\n      }\n    }\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "Cargar CSV/XLSX",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "x-api-key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Idempotency-Key",
                "value": "UPLOAD-2026-000001"
              }
            ],
            "url": "{{baseUrl}}/api/v1/payment-references/batches/upload",
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "format",
                  "value": "csv",
                  "type": "text"
                },
                {
                  "key": "providers",
                  "value": "openpay,bbva,banco_azteca,santander",
                  "type": "text"
                },
                {
                  "key": "file",
                  "type": "file",
                  "src": []
                }
              ]
            },
            "description": "Columnas recomendadas: external_id, customer_id, amount, description, expiration_date, customer_name, customer_email, customer_phone, period. Para alto volumen se recomienda JSON."
          }
        },
        {
          "name": "Consultar lote",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "x-api-key",
                "value": "{{apiKey}}"
              }
            ],
            "url": "{{baseUrl}}/api/v1/payment-references/batches/{{batchId}}"
          }
        },
        {
          "name": "Consultar items de lote",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "x-api-key",
                "value": "{{apiKey}}"
              }
            ],
            "url": "{{baseUrl}}/api/v1/payment-references/batches/{{batchId}}/items"
          },
          "description": "La respuesta actual devuelve los items del lote y metadata de paginacion simple."
        }
      ]
    },
    {
      "name": "Webhook Openpay",
      "item": [
        {
          "name": "Ejemplo payment.paid",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-openpay-signature",
                "value": ""
              }
            ],
            "url": "{{baseUrl}}/api/v1/webhooks/openpay",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"id\": \"evt_123\",\n  \"type\": \"payment.paid\",\n  \"event_date\": \"2026-06-22T10:20:30-06:00\",\n  \"transaction\": {\n    \"id\": \"tr_123\",\n    \"order_id\": \"payord_xxx\",\n    \"status\": \"completed\",\n    \"amount\": 248.5,\n    \"currency\": \"MXN\"\n  }\n}"
            },
            "description": "Este endpoint lo invoca Openpay. transaction.order_id es payment_order_id tecnico, no external_id."
          }
        }
      ]
    },
    {
      "name": "Reconciliation",
      "item": [
        {
          "name": "Conciliar referencias pendientes",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{apiKey}}"
              }
            ],
            "url": "{{baseUrl}}/api/v1/reconciliation",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"references\": [\n    \"RECIBO-2026-000001\"\n  ]\n}"
            }
          },
          "description": "Conciliacion disponible para referencias Paynet/Openpay. Las referencias BBVA, Banco Azteca y Santander son generadas localmente y no tienen API bancaria externa en esta version."
        },
        {
          "name": "Crear lote de conciliacion",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{apiKey}}"
              }
            ],
            "url": "{{baseUrl}}/api/v1/reconciliation/batches",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"references\": [\n    \"RECIBO-2026-000001\"\n  ]\n}"
            }
          }
        }
      ]
    }
  ]
}
