{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://forgecascade.org/buy.schema.json",
  "title": "Forge Cascade paid access router",
  "description": "Machine-readable schema for Forge same-origin buy routes and Stripe checkout fallbacks.",
  "type": "object",
  "required": [
    "$schema",
    "updated",
    "name",
    "legal_name",
    "currency",
    "checkout_routes",
    "recommended_first_checkout",
    "recommended_quick_checkout",
    "offers",
    "intent_routes"
  ],
  "properties": {
    "$schema": {
      "const": "https://forgecascade.org/buy.schema.json"
    },
    "updated": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "legal_name": {
      "type": "string"
    },
    "currency": {
      "const": "USD"
    },
    "checkout_routes": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "format": "uri",
        "pattern": "^https://forgecascade\\.org/buy/"
      }
    },
    "recommended_first_checkout": {
      "$ref": "#/$defs/offer"
    },
    "recommended_quick_checkout": {
      "$ref": "#/$defs/offer"
    },
    "fast_paid_starts": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/offer"
      }
    },
    "offers": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/offer"
      }
    },
    "proof_links": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/proof_link"
      }
    },
    "intent_routes": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "intent",
          "recommended_offer",
          "price_usd",
          "route_url",
          "checkout_url"
        ],
        "properties": {
          "intent": {
            "type": "string"
          },
          "recommended_offer": {
            "type": "string"
          },
          "price_usd": {
            "type": "number",
            "minimum": 0
          },
          "route_url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://forgecascade\\.org/buy/"
          },
          "checkout_url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://buy\\.stripe\\.com/"
          }
        },
        "additionalProperties": true
      }
    }
  },
  "$defs": {
    "proof_link": {
      "type": "object",
      "required": [
        "name",
        "url",
        "status"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "status": {
          "const": "live_listing"
        },
        "kind": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "offer": {
      "type": "object",
      "required": [
        "name",
        "price_usd",
        "route_url",
        "checkout_url"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "price": {
          "type": "number",
          "minimum": 0
        },
        "price_usd": {
          "type": "number",
          "minimum": 0
        },
        "cadence": {
          "type": "string"
        },
        "category": {
          "type": "string"
        },
        "preferred_url": {
          "type": "string",
          "format": "uri"
        },
        "route_url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://forgecascade\\.org/buy/"
        },
        "checkout_url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://buy\\.stripe\\.com/"
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
