{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.talleyit.com/proofrail-order-intent.schema.json",
  "title": "ProofRail Order Intent",
  "description": "A non-custodial Talley IT checkout packet. It records purchase intent, a timed payment wrapper, and a receipt hash; it does not authorize or execute payment.",
  "type": "object",
  "required": [
    "schema",
    "intent_id",
    "created_at",
    "expires_at",
    "merchant",
    "product",
    "seal",
    "customer",
    "request",
    "payment_wrapper",
    "proofrail_handoff",
    "boundaries",
    "receipt"
  ],
  "properties": {
    "schema": {
      "const": "proofrail.order_intent.v2"
    },
    "intent_id": {
      "type": "string",
      "pattern": "^PR-ORDER-[0-9]{14}-[0-9a-f]{12}$"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time"
    },
    "merchant": {
      "type": "object",
      "required": ["name", "jurisdiction", "public_site"],
      "properties": {
        "name": {"const": "Talley IT LLC"},
        "jurisdiction": {"type": "string"},
        "public_site": {"type": "string"}
      },
      "additionalProperties": false
    },
    "product": {
      "type": "object",
      "required": ["id", "name", "pricing", "kind"],
      "properties": {
        "id": {"type": "string"},
        "name": {"type": "string"},
        "pricing": {"type": "string"},
        "kind": {"type": "string"}
      },
      "additionalProperties": false
    },
    "seal": {
      "type": "object",
      "required": [
        "schema",
        "seal_id",
        "display_code",
        "status",
        "subject",
        "visible_claim",
        "binds",
        "user_action"
      ],
      "properties": {
        "schema": {"const": "proofrail.seal.v1"},
        "seal_id": {
          "type": "string",
          "pattern": "^PR-SEAL-[0-9a-f]{20}$"
        },
        "display_code": {
          "type": "string",
          "pattern": "^PRS-[0-9A-F]{6}-[0-9A-F]{6}$"
        },
        "status": {"const": "RECORD_MADE_VERIFIABLE_PAYMENT_NOT_VERIFIED"},
        "subject": {"type": "string"},
        "visible_claim": {"type": "string"},
        "binds": {
          "type": "array",
          "items": {"type": "string"},
          "minItems": 1
        },
        "user_action": {"type": "string"}
      },
      "additionalProperties": false
    },
    "customer": {
      "type": "object",
      "required": ["name", "email"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "email": {"type": "string", "minLength": 3}
      },
      "additionalProperties": false
    },
    "request": {
      "type": "object",
      "required": ["notes", "source_url"],
      "properties": {
        "notes": {"type": "string"},
        "source_url": {"type": "string"}
      },
      "additionalProperties": false
    },
    "payment_wrapper": {
      "type": "object",
      "required": ["schema", "wrapper_id", "status", "rail", "payee", "amount_hint", "memo", "token", "execution_boundary"],
      "properties": {
        "schema": {"const": "proofrail.payment_wrapper.v1"},
        "wrapper_id": {
          "type": "string",
          "pattern": "^PR-WRAP-[0-9a-f]{24}$"
        },
        "status": {"const": "CREATED_AWAITING_CUSTOMER_BANK_ACTION"},
        "rail": {"const": "Zelle/manual bank rail"},
        "payee": {
          "type": "object",
          "required": ["label", "rail", "zelle_id"],
          "properties": {
            "label": {"const": "Talley IT LLC"},
            "rail": {"const": "Zelle/manual bank rail"},
            "zelle_id": {"const": "talleyit"}
          },
          "additionalProperties": false
        },
        "amount_hint": {"type": "string"},
        "memo": {
          "type": "string",
          "pattern": "^PR-ORDER-[0-9]{14}-[0-9a-f]{12}$"
        },
        "token": {
          "type": "object",
          "required": ["kind", "ttl_minutes", "expires_at", "scope"],
          "properties": {
            "kind": {"const": "timed_payment_reference"},
            "ttl_minutes": {"const": 15},
            "expires_at": {"type": "string", "format": "date-time"},
            "scope": {"type": "string"}
          },
          "additionalProperties": false
        },
        "execution_boundary": {
          "type": "object",
          "required": [
            "automatic_transfer",
            "bank_credentials_collected",
            "payment_initiated_by_site",
            "custody_taken",
            "customer_controls_bank_action"
          ],
          "properties": {
            "automatic_transfer": {"const": false},
            "bank_credentials_collected": {"const": false},
            "payment_initiated_by_site": {"const": false},
            "custody_taken": {"const": false},
            "customer_controls_bank_action": {"const": true}
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "proofrail_handoff": {
      "type": "object",
      "required": [
        "status",
        "custody",
        "payment_started",
        "payment_collected_by_page",
        "email_required_by_checkout",
        "expected_next_step",
        "settlement_path"
      ],
      "properties": {
        "status": {"const": "READY_FOR_CUSTOMER_BANK_ACTION"},
        "custody": {"const": "none"},
        "payment_started": {"const": false},
        "payment_collected_by_page": {"const": false},
        "email_required_by_checkout": {"const": true},
        "expected_next_step": {"type": "string"},
        "settlement_path": {"type": "string"}
      },
      "additionalProperties": false
    },
    "boundaries": {
      "type": "object",
      "required": [
        "no_stripe",
        "no_marketplace_checkout",
        "no_bank_login",
        "no_bank_credentials",
        "no_funds_custodied_by_talley_it_site",
        "no_payment_authorized_by_packet"
      ],
      "properties": {
        "no_stripe": {"const": true},
        "no_marketplace_checkout": {"const": true},
        "no_bank_login": {"const": true},
        "no_bank_credentials": {"const": true},
        "no_funds_custodied_by_talley_it_site": {"const": true},
        "no_payment_authorized_by_packet": {"const": true}
      },
      "additionalProperties": false
    },
    "receipt": {
      "type": "object",
      "required": ["algorithm", "digest", "canonicalization", "signed_material"],
      "properties": {
        "algorithm": {"const": "SHA-256"},
        "digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "canonicalization": {"const": "sorted-json-v1"},
        "signed_material": {"type": "string"}
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
