{
  "openapi": "3.1.0",
  "info": {
    "title": "LetaCloset Shopping API",
    "version": "1.0.0",
    "description": "Discover products and prepare a hosted Stripe checkout. This API does not accept card details or complete payments."
  },
  "servers": [
    {
      "url": "https://www.letacloset.flyoverink.com"
    }
  ],
  "paths": {
    "/catalog.json": {
      "get": {
        "operationId": "getCatalog",
        "summary": "Get products, sizes, prices in cents, shipping and policies",
        "responses": {
          "200": {
            "description": "Current catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "products",
                    "shipping",
                    "limits"
                  ],
                  "properties": {
                    "products": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/config": {
      "get": {
        "operationId": "getCheckoutReadiness",
        "summary": "Check live checkout availability before preparing a purchase",
        "responses": {
          "200": {
            "description": "Current payment readiness",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "checkoutEnabled"
                  ],
                  "properties": {
                    "checkoutEnabled": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/checkout": {
      "post": {
        "operationId": "createCheckout",
        "summary": "Prepare a Stripe-hosted checkout; does not charge the customer",
        "description": "Obtain the shopper�s product, size and quantity choices. Check readiness first. Use one Idempotency-Key per unchanged purchase attempt. Present the returned URL for authorized payment completion. Never claim payment succeeded based on this response.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{8,128}$"
            },
            "description": "Reuse for retries of the identical request. Generate a new key when the bag changes."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "items"
                ],
                "properties": {
                  "items": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 12,
                    "description": "At most 20 pieces total.",
                    "items": {
                      "type": "object",
                      "required": [
                        "productId",
                        "size",
                        "qty"
                      ],
                      "properties": {
                        "productId": {
                          "type": "string",
                          "enum": [
                            "black",
                            "red",
                            "purple",
                            "main-character",
                            "faith-white",
                            "walk-by-faith",
                            "legacy-in-every-stitch",
                            "own-pace",
                            "grace-in-the-growing",
                            "made-of-many-stories",
                            "quietly-unstoppable"
                          ]
                        },
                        "size": {
                          "type": "string",
                          "enum": [
                            "S",
                            "M",
                            "L",
                            "XL",
                            "XXL"
                          ]
                        },
                        "qty": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 10
                        }
                      }
                    }
                  },
                  "giftNote": {
                    "type": "string",
                    "maxLength": 250
                  }
                }
              },
              "example": {
                "items": [
                  {
                    "productId": "black",
                    "size": "M",
                    "qty": 1
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Hosted payment URL, not payment confirmation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "url"
                  ],
                  "properties": {
                    "url": {
                      "type": "string",
                      "format": "uri"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Request failed; read error before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Request failed; read error before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Request failed; read error before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/order": {
      "get": {
        "operationId": "getOrderConfirmation",
        "summary": "Verify payment using the private session reference from the Stripe return URL",
        "description": "Treat session_id as private. Do not publish or log it.",
        "parameters": [
          {
            "name": "session_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^cs_(test|live)_[A-Za-z0-9]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Verified payment",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "orderNumber": {
                      "type": "string"
                    },
                    "paymentStatus": {
                      "type": "string",
                      "enum": [
                        "paid",
                        "no_payment_required"
                      ]
                    },
                    "amountTotal": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "currency": {
                      "type": "string"
                    },
                    "customerEmail": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Request failed; read error before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Request failed; read error before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Request failed; read error before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Request failed; read error before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
