{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/recur-tw/json-schema/recur-tw-create-checkout-session-request-schema.json",
  "title": "CreateCheckoutSessionRequest",
  "description": "Identify the product by `productId` or `productSlug`; at least one is required.\nWhen both are sent, `productId` wins.\n",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/recur-tw-openapi.json#/components/schemas/CreateCheckoutSessionRequest",
  "type": "object",
  "required": [
    "successUrl",
    "cancelUrl"
  ],
  "anyOf": [
    {
      "required": [
        "productId"
      ]
    },
    {
      "required": [
        "productSlug"
      ]
    }
  ],
  "properties": {
    "productId": {
      "type": "string",
      "description": "Product ID, a CUID returned by the API"
    },
    "productSlug": {
      "type": "string",
      "description": "Product slug, the URL-safe name chosen when the product was created.\nAn alternative to `productId`.\n"
    },
    "mode": {
      "type": "string",
      "enum": [
        "PAYMENT",
        "SUBSCRIPTION",
        "SETUP"
      ],
      "default": "PAYMENT",
      "description": "Checkout mode:\n- `PAYMENT`: one-time payment\n- `SUBSCRIPTION`: subscription, binds the card\n- `SETUP`: save the card only, no charge\n"
    },
    "successUrl": {
      "type": "string",
      "format": "uri",
      "description": "Redirect URL after a successful payment. HTTPS is required in production.\nFor local development the API also accepts `http://` on `localhost`, `127.0.0.1`\nand any `.local`, `.test` or `.dev` host.\nSupports the `{CHECKOUT_SESSION_ID}` placeholder.\n"
    },
    "cancelUrl": {
      "type": "string",
      "format": "uri",
      "description": "Redirect URL when the customer cancels. HTTPS is required in production; the same\nlocal-development hosts allowed for `successUrl` are accepted here.\n"
    },
    "customerEmail": {
      "type": "string",
      "format": "email",
      "description": "Pre-fill the customer's email (optional).\nWhen omitted, the customer enters it on the checkout page.\nAn email is always required to complete checkout, for the receipt.\n"
    },
    "customerName": {
      "type": "string",
      "description": "Pre-fill the customer's name (optional).\nWhen omitted, the customer can enter it on the checkout page.\n"
    },
    "promotionCode": {
      "type": "string",
      "description": "Promotion code to apply up front (optional).\nThe discount is calculated at creation and recorded on the session and the order.\n"
    },
    "collectPaymentMethod": {
      "type": "string",
      "enum": [
        "always",
        "if_required"
      ],
      "default": "always",
      "description": "When to collect a card:\n- `always` (default): ask for a card even at NT$0, with an NT$2 verification charge\n- `if_required`: skip the card at NT$0 and complete the subscription directly\n"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": true,
      "description": "Custom metadata (secret key only)"
    }
  }
}