{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/recur-tw/json-schema/recur-tw-create-checkout-session-response-schema.json",
  "title": "CreateCheckoutSessionResponse",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/recur-tw-openapi.json#/components/schemas/CreateCheckoutSessionResponse",
  "type": "object",
  "required": [
    "id",
    "url",
    "expires_at",
    "amount",
    "requires_payment_method"
  ],
  "properties": {
    "id": {
      "type": "string",
      "description": "Checkout Session ID"
    },
    "url": {
      "type": "string",
      "format": "uri",
      "description": "Hosted checkout page URL"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the session expires (30 minutes after creation)"
    },
    "amount": {
      "type": "integer",
      "description": "Amount actually charged after discount (whole TWD)"
    },
    "requires_payment_method": {
      "type": "boolean",
      "description": "Whether a card is required. Derived from `collectPaymentMethod` and the amount:\n- `always` → always `true`\n- `if_required` with amount > 0 → `true`\n- `if_required` with amount = 0 → `false`\n"
    },
    "client_secret": {
      "type": "string",
      "description": "PaymentIntent client secret, used by the client SDK to poll status safely"
    },
    "discount": {
      "type": "object",
      "description": "Discount details, present only when a promotion code was applied",
      "properties": {
        "code": {
          "type": "string",
          "description": "Promotion code"
        },
        "coupon_id": {
          "type": "string",
          "description": "Coupon ID"
        },
        "coupon_name": {
          "type": "string",
          "description": "Coupon name"
        },
        "discount_type": {
          "type": "string",
          "enum": [
            "PERCENTAGE",
            "FIXED_AMOUNT",
            "FIRST_PERIOD_PRICE"
          ]
        },
        "discount_amount": {
          "type": "integer",
          "description": "Discount amount (whole TWD)"
        },
        "final_amount": {
          "type": "integer",
          "description": "Amount after discount"
        },
        "original_amount": {
          "type": "integer",
          "description": "Original price"
        }
      }
    }
  }
}