{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:sitla:payments:1:schema:payment-event",
  "$comment": "SPDX-License-Identifier: CC0-1.0; Stripe online adapter, not a new wire/1 record or proof of provider execution.",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048
    },
    "profile": {
      "const": "sitla-online-payment-event/1"
    },
    "eventId": {
      "type": "string",
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
    },
    "sharedEventReference": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048
    },
    "recipientRole": {
      "enum": [
        "buyer",
        "seller"
      ]
    },
    "transactionId": {
      "type": "string",
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
    },
    "allocationId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048
    },
    "buyer": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        "controllerDid": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 2048
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "id",
        "controllerDid"
      ],
      "additionalProperties": false
    },
    "seller": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        "controllerDid": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 2048
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "id",
        "controllerDid"
      ],
      "additionalProperties": false
    },
    "stage": {
      "enum": [
        "instruction",
        "checkout",
        "authorization",
        "hold",
        "cancellation",
        "capture",
        "transfer",
        "refund",
        "reversal",
        "dispute",
        "expiry",
        "failure"
      ]
    },
    "outcome": {
      "enum": [
        "accepted",
        "requested",
        "pending",
        "confirmed",
        "failed",
        "reversed"
      ]
    },
    "currency": {
      "const": "JPY"
    },
    "currencyExponent": {
      "const": 0
    },
    "amountMinor": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        {
          "type": "null"
        }
      ]
    },
    "amountBasis": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048
    },
    "originalGrossMinor": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "platformFeeMinor": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "sellerNetMinor": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "provider": {
      "const": "Stripe"
    },
    "providerReference": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        {
          "type": "null"
        }
      ]
    },
    "providerConfirmed": {
      "type": "boolean"
    },
    "occurredAt": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d(?:\\.\\d{3})?Z$"
        },
        {
          "type": "null"
        }
      ]
    },
    "observedAt": {
      "type": "string",
      "pattern": "^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d(?:\\.\\d{3})?Z$"
    },
    "providerSignature": {
      "const": false
    },
    "collection": {
      "type": "object",
      "properties": {
        "policy": {
          "const": "sitla-collection-agency/1"
        },
        "authorizationId": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "buyerPriceDebt": {
          "const": "discharged-on-valid-stripe-capture"
        },
        "grossAmountMinor": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "noSecondCollectionFromBuyer": {
          "const": true
        },
        "sellerRemittance": {
          "const": "separate-operator-obligation"
        },
        "scope": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        }
      },
      "required": [
        "policy",
        "authorizationId",
        "buyerPriceDebt",
        "grossAmountMinor",
        "noSecondCollectionFromBuyer",
        "sellerRemittance",
        "scope"
      ],
      "additionalProperties": false
    },
    "sequence": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "predecessorDigest": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "approvalReference": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "terms": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "itemId": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "profileVersion": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "planIndex": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "grossMinor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "feeMinor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "netMinor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "termsDigest": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "itemId",
          "profileVersion",
          "planIndex",
          "grossMinor",
          "feeMinor",
          "netMinor",
          "termsDigest"
        ],
        "additionalProperties": false
      },
      "minItems": 1,
      "maxItems": 100
    },
    "limitations": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 2048
      },
      "minItems": 1,
      "maxItems": 100
    }
  },
  "required": [
    "id",
    "profile",
    "eventId",
    "sharedEventReference",
    "recipientRole",
    "transactionId",
    "allocationId",
    "buyer",
    "seller",
    "stage",
    "outcome",
    "currency",
    "currencyExponent",
    "amountMinor",
    "amountBasis",
    "originalGrossMinor",
    "platformFeeMinor",
    "sellerNetMinor",
    "provider",
    "providerReference",
    "providerConfirmed",
    "occurredAt",
    "observedAt",
    "providerSignature",
    "sequence",
    "predecessorDigest",
    "approvalReference",
    "terms",
    "limitations"
  ],
  "additionalProperties": false
}
