{
  "openapi": "3.1.0",
  "info": {
    "title": "Payment CytechTeam Dev API",
    "version": "1.0.0",
    "description": "Public integration subset; see /llms-full.txt for complete documentation."
  },
  "servers": [
    {
      "url": "https://payment.cytechteam.dev"
    }
  ],
  "components": {
    "securitySchemes": {
      "MerchantBearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "CreateCheckout": {
        "type": "object",
        "required": [
          "merchant_ref",
          "amount"
        ],
        "properties": {
          "merchant_ref": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "amount": {
            "type": "string"
          },
          "verification_method": {
            "type": "string",
            "enum": [
              "decimal",
              "name_exact",
              "account_last4",
              "bank"
            ]
          },
          "verification_value": {
            "type": "string"
          },
          "amount_mode": {
            "type": "string",
            "enum": [
              "exact",
              "unique_cents"
            ]
          },
          "receiver_promptpay": {
            "type": "string"
          },
          "receiver_bank": {
            "type": "string"
          },
          "receiver_last4": {
            "type": "string"
          }
        }
      }
    }
  },
  "paths": {
    "/v1/checkouts": {
      "post": {
        "summary": "Create checkout",
        "security": [
          {
            "MerchantBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCheckout"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "401": {
            "description": "Unauthorized"
          },
          "409": {
            "description": "Reference conflict"
          },
          "422": {
            "description": "Validation error"
          }
        }
      }
    },
    "/v1/checkouts/{pay_id}": {
      "get": {
        "summary": "Retrieve checkout",
        "security": [
          {
            "MerchantBearer": []
          }
        ],
        "parameters": [
          {
            "name": "pay_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Checkout details"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/v1/checkouts/{pay_id}/cancel": {
      "post": {
        "summary": "Cancel a pending checkout (idempotent; not a refund)",
        "security": [{"MerchantBearer": []}],
        "parameters": [{"name":"pay_id","in":"path","required":true,"schema":{"type":"string"}}],
        "requestBody": {"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false}}}},
        "responses": {
          "200": {"description":"Checkout is CANCELLED (includes checkout, cancelled_at and cancelled_by)"},
          "401": {"description":"Missing/invalid merchant credentials"},
          "404": {"description":"Checkout not found in merchant/project scope"},
          "409": {"description":"Already PAID or expired"}
        }
      }
    },
    "/pay/{pay_id}/cancel": {
      "post": {
        "summary": "Cancel from hosted checkout URL (high-entropy link is a limited capability)",
        "parameters": [{"name":"pay_id","in":"path","required":true,"schema":{"type":"string"}}],
        "requestBody": {"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false}}}},
        "responses": {
          "200": {"description":"Checkout cancelled"},
          "401": {"description":"Cross-origin cancellation rejected"},
          "409": {"description":"Already PAID or expired"}
        }
      }
    },
    "/pay/{pay_id}/status": {
      "get": {
        "summary": "Read public status",
        "parameters": [
          {
            "name": "pay_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payment status"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    }
  }
}
