{
  "openapi": "3.1.0",
  "info": {
    "title": "CryptiumPay Merchant API",
    "version": "2026-10-25",
    "description": "External merchant integration contract. Sign parsed JSON with HMAC-SHA256 using the merchant API key. No browser credential playground. Example addresses and hosts are placeholders. Documentation revision is not an API version prefix."
  },
  "servers": [
    {
      "url": "/",
      "description": "Public API origin for your deployment."
    }
  ],
  "tags": [
    {
      "name": "Invoices"
    },
    {
      "name": "Catalog"
    },
    {
      "name": "Checkout"
    }
  ],
  "paths": {
    "/api/invoices": {
      "post": {
        "operationId": "createInvoice",
        "tags": [
          "Invoices"
        ],
        "summary": "Create an invoice and hosted checkout URL.",
        "security": [
          {
            "merchantId": [],
            "signature": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateInvoice"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Invoice creation summary, including on an identical successful retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceCreated"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request; path validation can use a standard HTTP error envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/DomainError"
                    },
                    {
                      "$ref": "#/components/schemas/HttpError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, inactive, or invalid merchant credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpError"
                }
              }
            }
          },
          "403": {
            "description": "Source address not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpError"
                }
              }
            }
          },
          "404": {
            "description": "Item or invoice not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "409": {
            "description": "Order, item archive, expiry, or payment-method conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "422": {
            "description": "Unsupported payment currency, token, network, or method.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "502": {
            "description": "Upstream failure or invalid payment state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "503": {
            "description": "Dependency, rate, or configuration unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "504": {
            "description": "Upstream timeout; a mutation may have committed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          }
        }
      }
    },
    "/api/invoices/from-item": {
      "post": {
        "operationId": "createItemInvoice",
        "tags": [
          "Invoices"
        ],
        "summary": "Create an invoice from an immutable catalog-item snapshot.",
        "security": [
          {
            "merchantId": [],
            "signature": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateItemInvoice"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Invoice creation summary, including on an identical successful retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceCreated"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request; path validation can use a standard HTTP error envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/DomainError"
                    },
                    {
                      "$ref": "#/components/schemas/HttpError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, inactive, or invalid merchant credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpError"
                }
              }
            }
          },
          "403": {
            "description": "Source address not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpError"
                }
              }
            }
          },
          "404": {
            "description": "Item or invoice not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "409": {
            "description": "Order, item archive, expiry, or payment-method conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "422": {
            "description": "Unsupported payment currency, token, network, or method.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "502": {
            "description": "Upstream failure or invalid payment state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "503": {
            "description": "Dependency, rate, or configuration unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "504": {
            "description": "Upstream timeout; a mutation may have committed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          }
        }
      }
    },
    "/api/items": {
      "get": {
        "operationId": "listItems",
        "tags": [
          "Catalog"
        ],
        "summary": "List the authenticated merchant catalog.",
        "security": [
          {
            "merchantId": [],
            "signature": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size; query is a decimal string from 1 to 100. Default 25.",
            "schema": {
              "type": "string",
              "pattern": "^(?:[1-9]|[1-9][0-9]|100)$",
              "default": "25"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Non-negative offset with no leading zeroes, at most nine digits. Default 0.",
            "schema": {
              "type": "string",
              "pattern": "^(?:0|[1-9][0-9]{0,8})$",
              "default": "0"
            }
          },
          {
            "name": "include_archived",
            "in": "query",
            "required": false,
            "description": "Whether archived items are included. Default false.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "default": "false"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Catalog item array.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CatalogItems"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request; path validation can use a standard HTTP error envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/DomainError"
                    },
                    {
                      "$ref": "#/components/schemas/HttpError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, inactive, or invalid merchant credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpError"
                }
              }
            }
          },
          "403": {
            "description": "Source address not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpError"
                }
              }
            }
          },
          "404": {
            "description": "Item or invoice not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "409": {
            "description": "Order, item archive, expiry, or payment-method conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "422": {
            "description": "Unsupported payment currency, token, network, or method.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "502": {
            "description": "Upstream failure or invalid payment state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "503": {
            "description": "Dependency, rate, or configuration unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "504": {
            "description": "Upstream timeout; a mutation may have committed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          }
        }
      }
    },
    "/api/items/{item_id}": {
      "get": {
        "operationId": "getItem",
        "tags": [
          "Catalog"
        ],
        "summary": "Read one owned item, including archived items.",
        "security": [
          {
            "merchantId": [],
            "signature": []
          }
        ],
        "parameters": [
          {
            "name": "item_id",
            "in": "path",
            "required": true,
            "description": "Catalog item UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Owned catalog item.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CatalogItem"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request; path validation can use a standard HTTP error envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/DomainError"
                    },
                    {
                      "$ref": "#/components/schemas/HttpError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, inactive, or invalid merchant credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpError"
                }
              }
            }
          },
          "403": {
            "description": "Source address not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpError"
                }
              }
            }
          },
          "404": {
            "description": "Item or invoice not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "409": {
            "description": "Order, item archive, expiry, or payment-method conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "422": {
            "description": "Unsupported payment currency, token, network, or method.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "502": {
            "description": "Upstream failure or invalid payment state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "503": {
            "description": "Dependency, rate, or configuration unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "504": {
            "description": "Upstream timeout; a mutation may have committed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          }
        }
      }
    },
    "/api/invoices/{id}": {
      "get": {
        "operationId": "getPublicInvoice",
        "tags": [
          "Checkout"
        ],
        "summary": "Read the customer-facing invoice projection.",
        "security": [],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Invoice ID returned at creation.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public checkout representation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicInvoice"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request; path validation can use a standard HTTP error envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/DomainError"
                    },
                    {
                      "$ref": "#/components/schemas/HttpError"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Item or invoice not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "409": {
            "description": "Order, item archive, expiry, or payment-method conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "422": {
            "description": "Unsupported payment currency, token, network, or method.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "502": {
            "description": "Upstream failure or invalid payment state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "503": {
            "description": "Dependency, rate, or configuration unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          },
          "504": {
            "description": "Upstream timeout; a mutation may have committed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "merchantId": {
        "type": "apiKey",
        "in": "header",
        "name": "merchant-id",
        "description": "Active merchant ID."
      },
      "signature": {
        "type": "apiKey",
        "in": "header",
        "name": "signature",
        "description": "Computed lowercase hex HMAC-SHA256 of JSON.stringify(parsedBody || {}). Sign {} for a bodyless GET. This field is the signature, not the API key."
      }
    },
    "schemas": {
      "InvoiceFeePayer": {
        "type": "string",
        "enum": [
          "MERCHANT",
          "CUSTOMER"
        ],
        "default": "MERCHANT",
        "description": "Service-fee payer. MERCHANT keeps the customer total equal to the discounted goods amount; CUSTOMER adds the service fee after the discount. Omission preserves the merchant-paid default."
      },
      "InvoiceOriginalPrice": {
        "type": "string",
        "pattern": "^\\d+(?:\\.\\d+)?$",
        "maxLength": 160,
        "description": "Optional positive original price below 1e18 with at most 18 decimal places. Without a discount it must be at least the goods amount; with a discount it must equal the undiscounted base subtotal. The server infers it from the base when a discount is supplied.",
        "example": "100"
      },
      "InvoiceDiscount": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "value"
        ],
        "description": "Applied once to the complete base subtotal. Percentage must be positive and below 100; a fixed amount must be positive and below the subtotal. The final goods price must remain positive and fit Decimal(36,18).",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "PERCENT",
              "FIXED"
            ]
          },
          "value": {
            "type": "string",
            "pattern": "^\\d+(?:\\.\\d+)?$",
            "maxLength": 160,
            "description": "Positive plain decimal string with at most 18 decimal places. A percentage is expressed as 20 for twenty percent; FIXED uses the invoice currency.",
            "example": "20"
          }
        }
      },
      "InvoiceAppliedDiscount": {
        "type": "object",
        "required": [
          "type",
          "value",
          "amount"
        ],
        "description": "Saved server-calculated discount. The final goods price is rounded once to 18 decimal places with ROUND_HALF_UP; amount is the exact base subtotal minus that final goods price.",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "PERCENT",
              "FIXED"
            ]
          },
          "value": {
            "type": "string",
            "pattern": "^\\d+(?:\\.\\d+)?$",
            "example": "20"
          },
          "amount": {
            "type": "string",
            "pattern": "^\\d+(?:\\.\\d+)?$",
            "example": "20"
          }
        }
      },
      "InvoiceServiceFee": {
        "type": "object",
        "required": [
          "payer",
          "rate_bps",
          "amount",
          "currency"
        ],
        "description": "Service commission frozen at invoice creation, calculated after the discount and rounded to at most 18 decimal places with ROUND_HALF_UP. Added to the customer total only for CUSTOMER; deducted from merchant proceeds for MERCHANT.",
        "properties": {
          "payer": {
            "$ref": "#/components/schemas/InvoiceFeePayer"
          },
          "rate_bps": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000,
            "description": "Basis points: 150 means 1.5%.",
            "example": 150
          },
          "amount": {
            "type": "string",
            "pattern": "^\\d+(?:\\.\\d+)?$",
            "description": "Nonnegative service fee in the invoice currency.",
            "example": "1.2"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_-]{1,31}$",
            "example": "USD"
          }
        }
      },
      "InvoiceCustomerTotal": {
        "type": "string",
        "pattern": "^\\d+(?:\\.\\d+)?$",
        "maxLength": 160,
        "description": "Saved customer charge in the invoice currency: discounted goods amount plus the service fee only for CUSTOMER. Positive, below 1e18 and at most 18 decimal places. For legacy invoices without this field, use amount.",
        "example": "81.2"
      },
      "CreateInvoice": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "currency",
          "amount"
        ],
        "properties": {
          "fee_payer": {
            "$ref": "#/components/schemas/InvoiceFeePayer"
          },
          "original_price": {
            "$ref": "#/components/schemas/InvoiceOriginalPrice"
          },
          "discount": {
            "$ref": "#/components/schemas/InvoiceDiscount"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_-]{1,31}$",
            "description": "Pricing currency supported by the deployment. Fiat denomination does not imply fiat payment acceptance.",
            "example": "USD"
          },
          "amount": {
            "type": "string",
            "pattern": "^\\d+(?:\\.\\d+)?$",
            "maxLength": 160,
            "description": "Base price before any discount, as a positive plain decimal string below 1e18 with at most 18 decimal places. Response amount is the discounted goods price. No exponent or sign.",
            "example": "19.95"
          },
          "network": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_-]{1,31}$",
            "description": "Optional network constraint for a crypto-priced invoice. Does not select a method for a fiat-priced invoice."
          },
          "order_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "description": "Stable order reference. Retry the original base amount and pricing fields unchanged to retrieve the saved price, discount and fee snapshot. Changed pricing conditions return 409 ORDER_ID_ALREADY_EXISTS."
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "For a new invoice, a future ISO timestamp no more than 60 minutes ahead. Omission defaults to 30 minutes. Existing reservations and identical retries retain their original deadline."
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048,
            "pattern": "^https://",
            "description": "Public HTTPS receiver. Pass explicitly for invoice events; merchant settings are not inherited."
          },
          "success_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "maxLength": 2048,
            "description": "Absolute HTTP/HTTPS return URL without credentials. Not a payment confirmation. Null is allowed."
          },
          "description": {
            "type": "string",
            "maxLength": 2000,
            "description": "Optional invoice description; not returned in the create summary."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Optional JSON object. Not echoed by create, public read, or webhook payload."
          }
        }
      },
      "CreateItemInvoice": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "item_id"
        ],
        "properties": {
          "fee_payer": {
            "$ref": "#/components/schemas/InvoiceFeePayer"
          },
          "original_price": {
            "$ref": "#/components/schemas/InvoiceOriginalPrice"
          },
          "discount": {
            "$ref": "#/components/schemas/InvoiceDiscount"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_-]{1,31}$",
            "description": "Optional item-currency override. Omission uses the item currency."
          },
          "amount": {
            "type": "string",
            "pattern": "^\\d+(?:\\.\\d+)?$",
            "maxLength": 160,
            "description": "Base price override for ONE unit before any invoice discount. Omission uses the saved item price. The discount applies once to unit amount multiplied by quantity; the catalog item is unchanged.",
            "example": "19.95"
          },
          "network": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_-]{1,31}$",
            "description": "Optional network constraint for a crypto-priced invoice. Does not select a method for a fiat-priced invoice."
          },
          "order_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "description": "Stable order reference. Retry the original unit amount, quantity and pricing fields unchanged to retrieve the saved item, discount and fee snapshot. Changed conditions return 409 ORDER_ID_ALREADY_EXISTS."
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "For a new invoice, a future ISO timestamp no more than 60 minutes ahead. Omission defaults to 30 minutes. Existing reservations and identical retries retain their original deadline."
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048,
            "pattern": "^https://",
            "description": "Public HTTPS receiver. Pass explicitly for invoice events; merchant settings are not inherited."
          },
          "success_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "maxLength": 2048,
            "description": "Omission inherits the item URL. Null removes that URL, but merchant-level checkout redirect may still apply."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Optional JSON object. Not echoed by create, public read, or webhook payload."
          },
          "item_id": {
            "type": "string",
            "format": "uuid",
            "description": "An owned, non-archived catalog item."
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647,
            "default": 1,
            "description": "Number of units. Base subtotal is unit amount multiplied by quantity, before applying one invoice-level discount."
          }
        }
      },
      "ItemSnapshot": {
        "type": "object",
        "required": [
          "item_id",
          "name",
          "quantity",
          "unit_amount",
          "currency",
          "total_amount"
        ],
        "properties": {
          "item_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "icon_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "success_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "quantity": {
            "type": "integer"
          },
          "unit_amount": {
            "type": "string",
            "pattern": "^\\d+(?:\\.\\d+)?$",
            "maxLength": 160,
            "description": "Positive plain decimal string, below 1e18 and at most 18 decimal places. No exponent or sign.",
            "example": "19.95"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_-]{1,31}$",
            "description": "Uppercase currency or network code. Availability is deployment-specific."
          },
          "total_amount": {
            "type": "string",
            "pattern": "^\\d+(?:\\.\\d+)?$",
            "maxLength": 160,
            "description": "Saved base subtotal (unit_amount multiplied by quantity), before invoice discounts and service fees. This item snapshot is unchanged by invoice pricing.",
            "example": "19.95"
          }
        }
      },
      "InvoiceCreated": {
        "type": "object",
        "required": [
          "id",
          "amount",
          "currency",
          "currency_type",
          "status",
          "expires_at",
          "order_id",
          "url"
        ],
        "properties": {
          "fee_payer": {
            "$ref": "#/components/schemas/InvoiceFeePayer"
          },
          "original_price": {
            "$ref": "#/components/schemas/InvoiceOriginalPrice"
          },
          "discount": {
            "$ref": "#/components/schemas/InvoiceAppliedDiscount"
          },
          "fee": {
            "$ref": "#/components/schemas/InvoiceServiceFee"
          },
          "total_amount": {
            "$ref": "#/components/schemas/InvoiceCustomerTotal"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "amount": {
            "type": "string",
            "pattern": "^\\d+(?:\\.\\d+)?$",
            "maxLength": 160,
            "description": "Discounted goods amount, excluding any customer-paid service fee. Positive plain decimal string below 1e18 with at most 18 decimal places.",
            "example": "19.95"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_-]{1,31}$",
            "description": "Uppercase currency or network code. Availability is deployment-specific."
          },
          "currency_type": {
            "type": "string",
            "enum": [
              "FIAT",
              "CRYPTO"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "NEW",
              "PENDING",
              "CONFIRMING",
              "PAID",
              "PARTIALLY_PAID",
              "OVERPAID",
              "EXPIRED",
              "FAILED",
              "CANCELLED"
            ]
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "order_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "webhook_url": {
            "type": "string",
            "format": "uri"
          },
          "success_url": {
            "type": "string",
            "format": "uri"
          },
          "network": {
            "type": "string",
            "description": "Present only when one payment route is saved."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Use this returned checkout URL without constructing a hostname."
          },
          "item": {
            "$ref": "#/components/schemas/ItemSnapshot"
          }
        }
      },
      "CatalogItem": {
        "type": "object",
        "required": [
          "id",
          "merchant_id",
          "name",
          "amount",
          "currency",
          "description",
          "icon_url",
          "success_url",
          "archived_at",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "merchant_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "amount": {
            "type": "string",
            "pattern": "^\\d+(?:\\.\\d+)?$",
            "maxLength": 160,
            "description": "Positive plain decimal string, below 1e18 and at most 18 decimal places. No exponent or sign.",
            "example": "19.95"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_-]{1,31}$",
            "description": "Uppercase currency or network code. Availability is deployment-specific."
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "icon_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "success_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "archived_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CatalogItems": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/CatalogItem"
        },
        "description": "Plain array, newest creation then ID descending. No total or cursor wrapper."
      },
      "Network": {
        "type": "object",
        "required": [
          "code",
          "name"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "Token": {
        "type": "object",
        "required": [
          "code",
          "networks"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "networks": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 0
            },
            "description": "Indexes in the top-level networks array, not network codes."
          }
        }
      },
      "PublicPay": {
        "type": "object",
        "required": [
          "network",
          "token",
          "address",
          "amount_expected",
          "paid_amount"
        ],
        "properties": {
          "network": {
            "$ref": "#/components/schemas/Network"
          },
          "token": {
            "$ref": "#/components/schemas/Token"
          },
          "contract_address": {
            "type": [
              "string",
              "null"
            ]
          },
          "address": {
            "type": "string"
          },
          "amount_expected": {
            "type": "string",
            "pattern": "^\\d+(?:\\.\\d+)?$",
            "maxLength": 160,
            "description": "Positive plain decimal string, below 1e18 and at most 18 decimal places. No exponent or sign.",
            "example": "19.95"
          },
          "paid_amount": {
            "type": "string",
            "description": "Exact received decimal amount; can be zero."
          },
          "confirmations_required": {
            "type": "integer",
            "minimum": 0
          },
          "confirmations": {
            "type": "integer",
            "minimum": 0
          },
          "tx_hash": {
            "type": "string"
          }
        }
      },
      "PublicMerchant": {
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "icon_url_light": {
            "type": "string"
          },
          "icon_url_dark": {
            "type": "string"
          },
          "theme": {
            "type": "object",
            "description": "Optional sanitized checkout theme."
          }
        }
      },
      "PublicInvoice": {
        "type": "object",
        "required": [
          "id",
          "merchant_id",
          "merchant",
          "status",
          "expires_at",
          "amount",
          "currency",
          "currency_type",
          "networks",
          "tokens"
        ],
        "properties": {
          "fee_payer": {
            "$ref": "#/components/schemas/InvoiceFeePayer"
          },
          "original_price": {
            "$ref": "#/components/schemas/InvoiceOriginalPrice"
          },
          "discount": {
            "$ref": "#/components/schemas/InvoiceAppliedDiscount"
          },
          "fee": {
            "$ref": "#/components/schemas/InvoiceServiceFee"
          },
          "total_amount": {
            "$ref": "#/components/schemas/InvoiceCustomerTotal"
          },
          "id": {
            "type": "string"
          },
          "merchant_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "merchant": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PublicMerchant"
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "NEW",
              "PENDING",
              "CONFIRMING",
              "PAID",
              "PARTIALLY_PAID",
              "OVERPAID",
              "EXPIRED",
              "FAILED",
              "CANCELLED"
            ]
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "amount": {
            "type": "string",
            "pattern": "^\\d+(?:\\.\\d+)?$",
            "maxLength": 160,
            "description": "Discounted goods amount, excluding any customer-paid service fee. Positive plain decimal string below 1e18 with at most 18 decimal places.",
            "example": "19.95"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_-]{1,31}$",
            "description": "Uppercase currency or network code. Availability is deployment-specific."
          },
          "currency_type": {
            "type": "string",
            "enum": [
              "FIAT",
              "CRYPTO"
            ]
          },
          "success_url": {
            "type": "string",
            "format": "uri"
          },
          "networks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Network"
            }
          },
          "tokens": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Token"
            }
          },
          "pay": {
            "$ref": "#/components/schemas/PublicPay"
          },
          "item": {
            "$ref": "#/components/schemas/ItemSnapshot"
          },
          "order_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Saved merchant order reference for the payment summary."
          },
          "description": {
            "type": "string",
            "description": "Saved optional order description, without private invoice metadata."
          }
        }
      },
      "DomainError": {
        "type": "object",
        "required": [
          "statusCode",
          "code",
          "message"
        ],
        "properties": {
          "statusCode": {
            "type": "integer"
          },
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "HttpError": {
        "type": "object",
        "required": [
          "statusCode",
          "message"
        ],
        "properties": {
          "statusCode": {
            "type": "integer"
          },
          "message": {
            "type": "string"
          },
          "error": {
            "type": "string"
          }
        }
      }
    }
  }
}
