{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/depixapp-com/json-schema/depixapp-com-product-checkouts-response-schema.json",
  "title": "ProductCheckoutsResponse",
  "description": "Paginated checkouts of one product, with aggregates.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/depixapp-com-products-api-openapi.yml#/components/schemas/ProductCheckoutsResponse",
  "type": "object",
  "required": [
    "checkouts",
    "stats",
    "limit",
    "offset"
  ],
  "additionalProperties": false,
  "properties": {
    "checkouts": {
      "type": "array",
      "description": "Checkout rows for the product, newest first.",
      "items": {
        "type": "object",
        "description": "Product checkout list item.",
        "required": [
          "id",
          "status",
          "amount",
          "description",
          "created_at",
          "expires_at",
          "processing_at",
          "completed_at"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "description": "Checkout id (chk_*)."
          },
          "status": {
            "$ref": "#/$defs/CheckoutStatus"
          },
          "amount": {
            "type": "integer",
            "description": "Charge amount in cents."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Checkout description."
          },
          "created_at": {
            "type": "string",
            "description": "Creation timestamp (RFC 3339 UTC)."
          },
          "expires_at": {
            "type": "string",
            "description": "QR expiry timestamp (RFC 3339 UTC)."
          },
          "processing_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the checkout entered processing (null if never)."
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the checkout completed (null if never)."
          }
        }
      }
    },
    "stats": {
      "type": "object",
      "description": "Aggregates over the current filter.",
      "required": [
        "total",
        "completed",
        "completed_amount"
      ],
      "additionalProperties": false,
      "properties": {
        "total": {
          "type": "integer",
          "description": "Total checkouts matching the filter."
        },
        "completed": {
          "type": "integer",
          "description": "Completed checkouts."
        },
        "completed_amount": {
          "type": "integer",
          "description": "Sum of completed amounts in cents."
        }
      }
    },
    "limit": {
      "type": "integer",
      "description": "Applied page size (1–100)."
    },
    "offset": {
      "type": "integer",
      "description": "Applied offset."
    }
  },
  "$defs": {
    "CheckoutStatus": {
      "type": "string",
      "description": "Checkout lifecycle status — the enum below is the complete, closed set. `completed` is the terminal SUCCESS state. Terminal states (safe to stop polling): completed, expired, cancelled.",
      "enum": [
        "pending",
        "processing",
        "approved",
        "completed",
        "expired",
        "cancelled"
      ],
      "oneOf": [
        {
          "const": "pending",
          "description": "Awaiting payment; the PIX QR is active until expires_at."
        },
        {
          "const": "processing",
          "description": "PIX paid; settlement in progress."
        },
        {
          "const": "approved",
          "description": "Payment approved by the provider; DePix on the way to the merchant."
        },
        {
          "const": "completed",
          "description": "TERMINAL — success: DePix delivered to the merchant.",
          "x-terminal": true
        },
        {
          "const": "expired",
          "description": "TERMINAL — QR expired unpaid.",
          "x-terminal": true
        },
        {
          "const": "cancelled",
          "description": "TERMINAL — cancelled upstream by the provider (refund/error).",
          "x-terminal": true
        }
      ]
    }
  }
}