{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://docs.glomo.one/schemas/checkout-events/v1.json",
  "title": "Glomo checkout events v1",
  "description": "Glomo checkout events payload v1. Fields may be added within v1; ignore unknown fields and values.",
  "definitions": {
    "CheckoutStageChanged": {
      "title": "checkout.stage_changed",
      "description": "Sent when the customer reaches a new checkout stage or step.",
      "$schema": "http://json-schema.org/draft-07/schema#",
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "number",
              "const": 1
            },
            "method": {
              "type": "string",
              "minLength": 1
            },
            "resource": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "order",
                    "kyc",
                    "session"
                  ]
                },
                "id": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "required": [
                "type",
                "id"
              ]
            },
            "paymentId": {
              "type": "string",
              "minLength": 1
            },
            "journeyId": {
              "type": "string",
              "minLength": 1
            },
            "at": {
              "type": "string",
              "format": "date-time"
            },
            "flow": {
              "type": "string",
              "const": "payment"
            },
            "stage": {
              "type": "string",
              "minLength": 1,
              "description": "Known values: `opened`, `method_selected`, `details_submitted`, `attempt_created`, `customer_auth`, `provider_handoff`, `awaiting_confirmation`, `confirmed`, `failed`. New values can be added within v1; ignore values you do not recognise."
            },
            "step": {
              "type": "string",
              "minLength": 1
            },
            "provider": {
              "type": "string",
              "minLength": 1
            },
            "journeyType": {
              "type": "string",
              "enum": [
                "redirect",
                "native"
              ]
            },
            "errorCode": {
              "type": "string",
              "minLength": 1
            },
            "segment": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "total": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                }
              },
              "required": [
                "index",
                "total"
              ]
            }
          },
          "required": [
            "v",
            "resource",
            "journeyId",
            "at",
            "flow",
            "stage"
          ]
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "number",
              "const": 1
            },
            "method": {
              "type": "string",
              "minLength": 1
            },
            "resource": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "order",
                    "kyc",
                    "session"
                  ]
                },
                "id": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "required": [
                "type",
                "id"
              ]
            },
            "paymentId": {
              "type": "string",
              "minLength": 1
            },
            "journeyId": {
              "type": "string",
              "minLength": 1
            },
            "at": {
              "type": "string",
              "format": "date-time"
            },
            "flow": {
              "type": "string",
              "const": "kyc"
            },
            "stage": {
              "type": "string",
              "minLength": 1,
              "description": "Known values: `opened`, `in_progress`, `submitted`, `under_review`, `action_required`, `approved`, `rejected`, `expired`, `failed`. New values can be added within v1; ignore values you do not recognise."
            },
            "step": {
              "type": "string",
              "minLength": 1
            },
            "provider": {
              "type": "string",
              "minLength": 1
            },
            "journeyType": {
              "type": "string",
              "enum": [
                "redirect",
                "native"
              ]
            },
            "errorCode": {
              "type": "string",
              "minLength": 1
            },
            "segment": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "total": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                }
              },
              "required": [
                "index",
                "total"
              ]
            }
          },
          "required": [
            "v",
            "resource",
            "journeyId",
            "at",
            "flow",
            "stage"
          ]
        }
      ]
    },
    "CheckoutClosed": {
      "title": "checkout.closed",
      "description": "Sent when the checkout closes, at most once per open.",
      "$schema": "http://json-schema.org/draft-07/schema#",
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "number",
              "const": 1
            },
            "method": {
              "type": "string",
              "minLength": 1
            },
            "resource": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "order",
                    "kyc",
                    "session"
                  ]
                },
                "id": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "required": [
                "type",
                "id"
              ]
            },
            "paymentId": {
              "type": "string",
              "minLength": 1
            },
            "journeyId": {
              "type": "string",
              "minLength": 1
            },
            "at": {
              "type": "string",
              "format": "date-time"
            },
            "flow": {
              "type": "string",
              "const": "payment"
            },
            "lastStage": {
              "type": "string",
              "minLength": 1,
              "description": "Known values: `opened`, `method_selected`, `details_submitted`, `attempt_created`, `customer_auth`, `provider_handoff`, `awaiting_confirmation`, `confirmed`, `failed`. New values can be added within v1; ignore values you do not recognise."
            },
            "lastStep": {
              "type": "string",
              "minLength": 1
            },
            "reason": {
              "type": "string",
              "minLength": 1,
              "description": "Known values: `user_dismissed`, `user_cancelled`, `completed`, `error`, `confirmation_timeout`. New values can be added within v1; ignore values you do not recognise."
            }
          },
          "required": [
            "v",
            "resource",
            "journeyId",
            "at",
            "flow",
            "reason"
          ]
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "number",
              "const": 1
            },
            "method": {
              "type": "string",
              "minLength": 1
            },
            "resource": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "order",
                    "kyc",
                    "session"
                  ]
                },
                "id": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "required": [
                "type",
                "id"
              ]
            },
            "paymentId": {
              "type": "string",
              "minLength": 1
            },
            "journeyId": {
              "type": "string",
              "minLength": 1
            },
            "at": {
              "type": "string",
              "format": "date-time"
            },
            "flow": {
              "type": "string",
              "const": "kyc"
            },
            "lastStage": {
              "type": "string",
              "minLength": 1,
              "description": "Known values: `opened`, `in_progress`, `submitted`, `under_review`, `action_required`, `approved`, `rejected`, `expired`, `failed`. New values can be added within v1; ignore values you do not recognise."
            },
            "lastStep": {
              "type": "string",
              "minLength": 1
            },
            "reason": {
              "type": "string",
              "minLength": 1,
              "description": "Known values: `user_dismissed`, `user_cancelled`, `completed`, `error`, `confirmation_timeout`. New values can be added within v1; ignore values you do not recognise."
            }
          },
          "required": [
            "v",
            "resource",
            "journeyId",
            "at",
            "flow",
            "reason"
          ]
        }
      ]
    }
  }
}
