← All schemas

example.payment

Canonical URL
https://schematalog.com/api/schemas/example.payment/versions/1.0 (opens in a new tab)
Published
22 August 2026 23:11

Properties

ParameterDescriptionType RequiredNullableDefaultExample
amount Number Required
currency pattern ^[A-Z]{3}$ Optional
line_items List of Object Optional
method String, Object Required
refunded Boolean Optional false

Definition

{
  "type": "object",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "required": [
    "amount",
    "method"
  ],
  "properties": {
    "amount": {
      "type": "number",
      "minimum": 0
    },
    "method": {
      "oneOf": [
        {
          "enum": [
            "card",
            "cash"
          ],
          "type": "string"
        },
        {
          "type": "object",
          "properties": {
            "wallet": {
              "type": "string"
            }
          }
        }
      ]
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "refunded": {
      "type": "boolean",
      "default": false
    },
    "line_items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "sku": {
            "type": "string"
          }
        }
      }
    }
  },
  "$id": "https://schematalog.com/api/schemas/example.payment/versions/1.0",
  "title": "example.payment"
}
$id: https://schematalog.com/api/schemas/example.payment/versions/1.0
$schema: https://json-schema.org/draft/2020-12/schema
properties:
  amount:
    minimum: 0
    type: number
  currency:
    pattern: ^[A-Z]{3}$
    type: string
  line_items:
    items:
      properties:
        sku:
          type: string
      type: object
    type: array
  method:
    oneOf:
    - enum:
      - card
      - cash
      type: string
    - properties:
        wallet:
          type: string
      type: object
  refunded:
    default: false
    type: boolean
required:
- amount
- method
title: example.payment
type: object
from __future__ import annotations

from enum import Enum
from typing import List, Optional, Union

from pydantic import BaseModel, confloat, constr


class Method(Enum):
    card = 'card'
    cash = 'cash'


class Method1(BaseModel):
    wallet: Optional[str] = None


class LineItem(BaseModel):
    sku: Optional[str] = None


class ExamplePayment(BaseModel):
    amount: confloat(ge=0.0)
    method: Union[Method, Method1]
    currency: Optional[constr(pattern=r'^[A-Z]{3}$')] = None
    refunded: Optional[bool] = False
    line_items: Optional[List[LineItem]] = None
# This schema cannot be represented as Avro: Unsupported JSON Schema keyword: 'oneOf'.