{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "$ref": "#/components/schemas/WebhookEvent"
    },
    {
      "$ref": "#/components/schemas/WebhookChallenge"
    }
  ],
  "components": {
    "schemas": {
      "Meta": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "request_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The API request correlation ID."
          },
          "as_of": {
            "type": "string",
            "format": "date-time",
            "description": "The time represented by the response, in RFC 3339 format."
          },
          "sync_lag_seconds": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              {
                "type": "null"
              }
            ],
            "description": "Known reporting synchronization delay in seconds; null when unknown or not applicable."
          },
          "data_source": {
            "type": "string",
            "enum": [
              "cn",
              "us"
            ],
            "description": "The response source: cn for the China service or us for US reporting."
          }
        },
        "required": [
          "request_id",
          "data_source",
          "as_of",
          "sync_lag_seconds"
        ]
      },
      "Error": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "VALIDATION_FAILED",
              "UNAUTHENTICATED",
              "SCOPE_DENIED",
              "RESOURCE_NOT_FOUND",
              "VERSION_CONFLICT",
              "IDEMPOTENCY_CONFLICT",
              "REQUEST_IN_PROGRESS",
              "REFUND_WINDOW_EXPIRED",
              "REFUND_CAPACITY_EXCEEDED",
              "FUNDS_UNAVAILABLE",
              "APPROVAL_REQUIRED",
              "SELF_APPROVAL_FORBIDDEN",
              "APPROVAL_STALE",
              "ADVANCE_LIMIT_EXCEEDED",
              "POLICY_NOT_ACCEPTED",
              "PRODUCTION_NOT_READY",
              "CAPABILITY_UNAVAILABLE",
              "SUBJECT_MISMATCH",
              "EVIDENCE_REUSED",
              "CURSOR_EXPIRED",
              "RATE_LIMITED",
              "AUTHORITATIVE_UNAVAILABLE",
              "ENDPOINT_NOT_VERIFIED",
              "CONFIGURATION_INCOMPLETE",
              "STATE_CONFLICT",
              "UPLOAD_INCOMPLETE",
              "EVIDENCE_UNAVAILABLE",
              "BANK_RESULT_UNVERIFIED",
              "SECRET_RECOVERY_EXPIRED",
              "AUTH_STAGE_REQUIRED",
              "TWO_FACTOR_INVALID",
              "RECENT_AUTH_REQUIRED",
              "TEMPORARY_PASSWORD_EXPIRED"
            ]
          },
          "message": {
            "type": "string",
            "maxLength": 1024,
            "minLength": 1
          },
          "request_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The API request correlation ID."
          },
          "retryable": {
            "type": "boolean",
            "description": "Whether the request may be retried later. Preserve the original command and idempotency key."
          },
          "current_version": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991
              },
              {
                "type": "null"
              }
            ]
          },
          "operation_id": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 40
              },
              {
                "type": "null"
              }
            ],
            "description": "The asynchronous operation ID used to retrieve progress."
          },
          "status_path": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^/"
              },
              {
                "type": "null"
              }
            ],
            "description": "The relative API path used to retrieve the resource or operation. Resolve against the assigned trusted service."
          },
          "details": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "field": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 1024
                },
                "code": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 1024
                },
                "message": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 1024
                }
              },
              "required": [
                "field",
                "code",
                "message"
              ]
            },
            "minItems": 0,
            "maxItems": 100
          }
        },
        "required": [
          "code",
          "message",
          "request_id",
          "retryable",
          "current_version",
          "operation_id",
          "status_path",
          "details"
        ]
      },
      "App": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The public resource identifier."
          },
          "environment": {
            "type": "string",
            "enum": [
              "production"
            ],
            "description": "The payment environment. This edition supports production."
          },
          "status": {
            "type": "string",
            "enum": [
              "onboarding",
              "active",
              "suspended",
              "closing",
              "closed"
            ],
            "description": "The business state of the resource. HTTP 202 alone does not indicate completion."
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "The current resource version used for concurrency control."
          },
          "client_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The public customer ID associated with the application."
          },
          "enabled_payment_entries": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "wechat_app",
                "wechat_h5",
                "wechat_native",
                "alipay_app",
                "alipay_wap",
                "alipay_page",
                "alipay_qr",
                "hms_iap"
              ]
            },
            "maxItems": 100,
            "uniqueItems": true,
            "description": "Payment entries enabled for this application."
          },
          "us_app_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "description": "The US application UUID, separate from the payment application ID."
          }
        },
        "required": [
          "id",
          "client_id",
          "environment",
          "status",
          "enabled_payment_entries",
          "version",
          "us_app_id"
        ]
      },
      "Order": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The public resource identifier."
          },
          "app_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The platform application ID authorized by the credential."
          },
          "environment": {
            "type": "string",
            "enum": [
              "production"
            ],
            "description": "The payment environment. This edition supports production."
          },
          "amount_minor": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "currency": {
            "type": "string",
            "enum": [
              "CNY"
            ],
            "description": "The three-letter uppercase currency code."
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "unknown",
              "paid",
              "failed",
              "closed"
            ],
            "description": "The business state of the resource. HTTP 202 alone does not indicate completion."
          },
          "paid_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "An RFC 3339 timestamp with an explicit offset. Financial business dates use Asia/Shanghai."
          },
          "policy_snapshot_id": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 40
              },
              {
                "type": "null"
              }
            ],
            "description": "The public resource identifier."
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "The current resource version used for concurrency control."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "An RFC 3339 timestamp with an explicit offset. Financial business dates use Asia/Shanghai."
          },
          "payment_entry": {
            "type": "string",
            "enum": [
              "wechat_app",
              "wechat_h5",
              "wechat_native",
              "alipay_app",
              "alipay_wap",
              "alipay_page",
              "alipay_qr",
              "hms_iap"
            ],
            "description": "The payment provider and entry method, such as wechat_h5 or alipay_qr."
          },
          "paid_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "refunded_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "pending_refund_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Refund principal reserved by valid requests and provider executions in progress. A transfer between these stages is counted once."
          },
          "refund_request_deadline_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "A valid refund request must be received before this exclusive deadline. Null before payment."
          }
        },
        "required": [
          "id",
          "app_id",
          "environment",
          "payment_entry",
          "amount_minor",
          "paid_amount_minor",
          "refunded_amount_minor",
          "pending_refund_amount_minor",
          "currency",
          "status",
          "paid_at",
          "refund_request_deadline_at",
          "policy_snapshot_id",
          "version",
          "created_at"
        ]
      },
      "Refund": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The public resource identifier."
          },
          "app_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The platform application ID authorized by the credential."
          },
          "order_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The platform order ID. Your business order reference is external_order_id."
          },
          "amount_minor": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "currency": {
            "type": "string",
            "enum": [
              "CNY"
            ],
            "description": "The three-letter uppercase currency code."
          },
          "review_status": {
            "type": "string",
            "enum": [
              "received",
              "needs_materials",
              "under_review",
              "awaiting_funds",
              "approved",
              "rejected",
              "cancelled"
            ],
            "description": "The refund review state, separate from provider execution."
          },
          "execution_status": {
            "type": "string",
            "enum": [
              "not_submitted",
              "accepted",
              "submitting",
              "processing",
              "unknown",
              "succeeded",
              "failed",
              "cancelled"
            ],
            "description": "The provider execution state. unknown means that the result is unresolved."
          },
          "valid_received_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the valid refund request was received, used to assess the request deadline."
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "The public refund version. Advances when the request, execution, or confirmed economics change."
          },
          "execution_id": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 40
              },
              {
                "type": "null"
              }
            ],
            "description": "The provider-execution reference, or null before execution is created."
          },
          "economics": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "estimate": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/RefundEconomics"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "actual": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/RefundEconomics"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "estimate",
              "actual"
            ]
          }
        },
        "required": [
          "id",
          "app_id",
          "order_id",
          "amount_minor",
          "currency",
          "review_status",
          "execution_status",
          "valid_received_at",
          "version",
          "execution_id",
          "economics"
        ],
        "description": "The refund ID remains stable throughout review, provider execution, and economics updates. Its public version advances as these change."
      },
      "RefundInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "amount_minor": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "reason": {
            "type": "string",
            "enum": [
              "customer_request",
              "duplicate",
              "fraud",
              "service_issue",
              "consumer_complaint",
              "other"
            ]
          },
          "expected_order_version": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "amount_minor",
          "reason",
          "expected_order_version"
        ]
      },
      "RefundEligibility": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "order_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The platform order ID. Your business order reference is external_order_id."
          },
          "eligible": {
            "type": "boolean",
            "description": "Whether the order is eligible at the time of the check. Revalidated on submission."
          },
          "refundable_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Maximum refundable principal at the time of the check, in minor units. Revalidated on submission."
          },
          "order_version": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "checked_at": {
            "type": "string",
            "format": "date-time",
            "description": "An RFC 3339 timestamp with an explicit offset. Financial business dates use Asia/Shanghai."
          },
          "blocked_reasons": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 1024,
              "minLength": 1
            },
            "maxItems": 100,
            "uniqueItems": true
          },
          "refund_request_deadline_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "A valid refund request must be received before this exclusive deadline. Null before payment."
          }
        },
        "required": [
          "order_id",
          "eligible",
          "refundable_amount_minor",
          "refund_request_deadline_at",
          "order_version",
          "checked_at",
          "blocked_reasons"
        ]
      },
      "Balance": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "app_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The platform application ID authorized by the credential."
          },
          "currency": {
            "type": "string",
            "enum": [
              "CNY",
              "USD"
            ],
            "description": "The three-letter uppercase currency code."
          },
          "as_of": {
            "type": "string",
            "format": "date-time",
            "description": "The time represented by the response, in RFC 3339 format."
          },
          "locked_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "available_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "reserve_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "pending_refund_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Refund principal reserved by valid requests and provider executions in progress. A transfer between these stages is counted once."
          },
          "pending_settlement_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Funds reserved for a settlement that has not completed, in minor units."
          },
          "outstanding_debt_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "risk_hold_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "settlement_eligible_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          }
        },
        "required": [
          "app_id",
          "currency",
          "locked_amount_minor",
          "available_amount_minor",
          "reserve_amount_minor",
          "pending_refund_amount_minor",
          "pending_settlement_amount_minor",
          "outstanding_debt_minor",
          "risk_hold_amount_minor",
          "as_of",
          "settlement_eligible_amount_minor"
        ],
        "description": "Sales reserved bucket is reserve; USD adjustment reservations are settlement pending. Risk holds overlay asset buckets; debt is separate. Eligibility is computed in CN and rechecked under locks."
      },
      "ReleaseStage": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The public resource identifier."
          },
          "lot_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The public resource identifier."
          },
          "due_at": {
            "type": "string",
            "format": "date-time",
            "description": "An RFC 3339 timestamp with an explicit offset. Financial business dates use Asia/Shanghai."
          },
          "blocked_reasons": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 1024,
              "minLength": 1
            },
            "maxItems": 100,
            "uniqueItems": true
          },
          "original_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "released_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "consumed_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          }
        },
        "required": [
          "id",
          "lot_id",
          "due_at",
          "original_amount_minor",
          "released_amount_minor",
          "consumed_amount_minor",
          "blocked_reasons"
        ]
      },
      "Operation": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The public resource identifier."
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "running",
              "succeeded",
              "failed",
              "manual_review"
            ],
            "description": "The business state of the resource. HTTP 202 alone does not indicate completion."
          },
          "resource": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ResourceRef"
              },
              {
                "type": "null"
              }
            ]
          },
          "failure_code": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ],
            "description": "The failure classification, or null when there is no recorded failure."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "An RFC 3339 timestamp with an explicit offset. Financial business dates use Asia/Shanghai."
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "An RFC 3339 timestamp with an explicit offset. Financial business dates use Asia/Shanghai."
          },
          "status_path": {
            "type": "string",
            "pattern": "^/",
            "description": "The relative API path used to retrieve the resource or operation. Resolve against the assigned trusted service."
          }
        },
        "required": [
          "id",
          "status",
          "resource",
          "failure_code",
          "created_at",
          "completed_at",
          "status_path"
        ]
      },
      "WebhookEvent": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "event_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The event identifier. Retries and replays of the same event retain this value."
          },
          "schema_version": {
            "type": "string",
            "enum": [
              "1"
            ],
            "description": "The event schema version, separate from the business resource version."
          },
          "type": {
            "type": "string",
            "enum": [
              "payment.succeeded",
              "payment.failed",
              "payment.closed",
              "refund.succeeded",
              "refund.failed",
              "hms.confirmation.required",
              "hms.confirmation.completed"
            ]
          },
          "app_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The platform application ID authorized by the credential."
          },
          "environment": {
            "type": "string",
            "enum": [
              "production"
            ],
            "description": "The payment environment. This edition supports production."
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "description": "An RFC 3339 timestamp with an explicit offset. Financial business dates use Asia/Shanghai."
          },
          "resource_version": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "The version of the resource represented by the event. Compare versions within the same resource."
          },
          "data": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/EventOrder"
              },
              {
                "$ref": "#/components/schemas/EventRefund"
              },
              {
                "$ref": "#/components/schemas/EventChannelConfirmation"
              }
            ]
          }
        },
        "required": [
          "event_id",
          "schema_version",
          "type",
          "app_id",
          "environment",
          "occurred_at",
          "resource_version",
          "data"
        ],
        "allOf": [
          {
            "if": {
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "payment.succeeded"
                  ]
                }
              }
            },
            "then": {
              "properties": {
                "data": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/EventOrder"
                    },
                    {
                      "properties": {
                        "status": {
                          "const": "paid",
                          "description": "The business state of the resource. HTTP 202 alone does not indicate completion."
                        },
                        "paid_amount_minor": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 9007199254740991,
                          "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
                        },
                        "paid_at": {
                          "type": "string",
                          "format": "date-time",
                          "description": "An RFC 3339 timestamp with an explicit offset. Financial business dates use Asia/Shanghai."
                        },
                        "refund_request_deadline_at": {
                          "type": "string",
                          "format": "date-time",
                          "description": "A valid refund request must be received before this exclusive deadline. Null before payment."
                        },
                        "policy_snapshot_id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 40,
                          "description": "The public resource identifier."
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "payment.failed"
                  ]
                }
              }
            },
            "then": {
              "properties": {
                "data": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/EventOrder"
                    },
                    {
                      "properties": {
                        "status": {
                          "const": "failed",
                          "description": "The business state of the resource. HTTP 202 alone does not indicate completion."
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "payment.closed"
                  ]
                }
              }
            },
            "then": {
              "properties": {
                "data": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/EventOrder"
                    },
                    {
                      "properties": {
                        "status": {
                          "const": "closed",
                          "description": "The business state of the resource. HTTP 202 alone does not indicate completion."
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "refund.succeeded"
                  ]
                }
              }
            },
            "then": {
              "properties": {
                "data": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/EventRefund"
                    },
                    {
                      "properties": {
                        "execution_status": {
                          "const": "succeeded",
                          "description": "The provider execution state. unknown means that the result is unresolved."
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "refund.failed"
                  ]
                }
              }
            },
            "then": {
              "properties": {
                "data": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/EventRefund"
                    },
                    {
                      "properties": {
                        "execution_status": {
                          "const": "failed",
                          "description": "The provider execution state. unknown means that the result is unresolved."
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "hms.confirmation.required"
                  ]
                }
              }
            },
            "then": {
              "properties": {
                "data": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/EventChannelConfirmation"
                    },
                    {
                      "properties": {
                        "status": {
                          "const": "awaiting_attestation",
                          "description": "The business state of the resource. HTTP 202 alone does not indicate completion."
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "hms.confirmation.completed"
                  ]
                }
              }
            },
            "then": {
              "properties": {
                "data": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/EventChannelConfirmation"
                    },
                    {
                      "properties": {
                        "status": {
                          "const": "confirmed",
                          "description": "The business state of the resource. HTTP 202 alone does not indicate completion."
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        ]
      },
      "WebhookChallenge": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "event_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The event identifier. Retries and replays of the same event retain this value."
          },
          "schema_version": {
            "type": "string",
            "enum": [
              "1"
            ],
            "description": "The event schema version, separate from the business resource version."
          },
          "type": {
            "type": "string",
            "enum": [
              "endpoint.verification"
            ]
          },
          "app_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The platform application ID authorized by the credential."
          },
          "environment": {
            "type": "string",
            "enum": [
              "production"
            ],
            "description": "The payment environment. This edition supports production."
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "description": "An RFC 3339 timestamp with an explicit offset. Financial business dates use Asia/Shanghai."
          },
          "data": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "endpoint_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 40,
                "description": "The webhook endpoint ID."
              },
              "challenge": {
                "type": "string",
                "minLength": 32,
                "maxLength": 256
              },
              "expires_at": {
                "type": "string",
                "format": "date-time",
                "description": "An RFC 3339 timestamp with an explicit offset. Financial business dates use Asia/Shanghai."
              }
            },
            "required": [
              "endpoint_id",
              "challenge",
              "expires_at"
            ]
          }
        },
        "required": [
          "event_id",
          "schema_version",
          "type",
          "app_id",
          "environment",
          "occurred_at",
          "data"
        ]
      },
      "ResourceRef": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "app",
              "order",
              "refund",
              "settlement",
              "case",
              "approval_case",
              "policy",
              "evidence",
              "credential",
              "webhook_endpoint",
              "payout_attempt",
              "ledger_entry",
              "admin_grant"
            ]
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The public resource identifier."
          }
        },
        "required": [
          "type",
          "id"
        ]
      },
      "RefundEconomics": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "developer_principal_reversal_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "platform_principal_reversal_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "original_payment_fee_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "developer_fee_already_borne_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "developer_fee_adjustment_minor": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "developer_refund_cost_minor": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "Principal reversal plus signed incremental original-fee adjustment; consumer refund principal is never reduced."
          },
          "outstanding_debt_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Debt as of calculated_at, not a live debt balance. Current outstanding debt is read from Balance."
          },
          "policy_snapshot_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The public resource identifier."
          },
          "calculated_at": {
            "type": "string",
            "format": "date-time",
            "description": "An RFC 3339 timestamp with an explicit offset. Financial business dates use Asia/Shanghai."
          }
        },
        "required": [
          "developer_principal_reversal_minor",
          "platform_principal_reversal_minor",
          "original_payment_fee_minor",
          "developer_fee_already_borne_minor",
          "developer_fee_adjustment_minor",
          "developer_refund_cost_minor",
          "outstanding_debt_minor",
          "policy_snapshot_id",
          "calculated_at"
        ]
      },
      "EventOrder": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The public resource identifier."
          },
          "app_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The platform application ID authorized by the credential."
          },
          "environment": {
            "type": "string",
            "enum": [
              "production"
            ],
            "description": "The payment environment. This edition supports production."
          },
          "amount_minor": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "currency": {
            "type": "string",
            "enum": [
              "CNY"
            ],
            "description": "The three-letter uppercase currency code."
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "unknown",
              "paid",
              "failed",
              "closed"
            ],
            "description": "The business state of the resource. HTTP 202 alone does not indicate completion."
          },
          "paid_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "An RFC 3339 timestamp with an explicit offset. Financial business dates use Asia/Shanghai."
          },
          "policy_snapshot_id": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 40
              },
              {
                "type": "null"
              }
            ],
            "description": "The public resource identifier."
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "The current resource version used for concurrency control."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "An RFC 3339 timestamp with an explicit offset. Financial business dates use Asia/Shanghai."
          },
          "payment_entry": {
            "type": "string",
            "enum": [
              "wechat_app",
              "wechat_h5",
              "wechat_native",
              "alipay_app",
              "alipay_wap",
              "alipay_page",
              "alipay_qr",
              "hms_iap"
            ],
            "description": "The payment provider and entry method, such as wechat_h5 or alipay_qr."
          },
          "paid_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "refunded_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "pending_refund_amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Refund principal reserved by valid requests and provider executions in progress. A transfer between these stages is counted once."
          },
          "refund_request_deadline_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "A valid refund request must be received before this exclusive deadline. Null before payment."
          }
        },
        "required": [
          "id",
          "app_id",
          "environment",
          "payment_entry",
          "amount_minor",
          "paid_amount_minor",
          "refunded_amount_minor",
          "pending_refund_amount_minor",
          "currency",
          "status",
          "paid_at",
          "refund_request_deadline_at",
          "policy_snapshot_id",
          "version",
          "created_at"
        ]
      },
      "EventRefund": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The public resource identifier."
          },
          "app_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The platform application ID authorized by the credential."
          },
          "order_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The platform order ID. Your business order reference is external_order_id."
          },
          "amount_minor": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "An integer in the smallest currency unit: fen for CNY or cents for USD."
          },
          "currency": {
            "type": "string",
            "enum": [
              "CNY"
            ],
            "description": "The three-letter uppercase currency code."
          },
          "review_status": {
            "type": "string",
            "enum": [
              "received",
              "needs_materials",
              "under_review",
              "awaiting_funds",
              "approved",
              "rejected",
              "cancelled"
            ],
            "description": "The refund review state, separate from provider execution."
          },
          "execution_status": {
            "type": "string",
            "enum": [
              "not_submitted",
              "accepted",
              "submitting",
              "processing",
              "unknown",
              "succeeded",
              "failed",
              "cancelled"
            ],
            "description": "The provider execution state. unknown means that the result is unresolved."
          },
          "valid_received_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the valid refund request was received, used to assess the request deadline."
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "The public refund version, updated as the refund lifecycle changes."
          },
          "execution_id": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 40
              },
              {
                "type": "null"
              }
            ],
            "description": "The provider-execution reference, or null before execution is created."
          },
          "economics": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "estimate": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/RefundEconomics"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "actual": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/RefundEconomics"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "estimate",
              "actual"
            ]
          }
        },
        "required": [
          "id",
          "app_id",
          "order_id",
          "amount_minor",
          "currency",
          "review_status",
          "execution_status",
          "valid_received_at",
          "version",
          "execution_id",
          "economics"
        ],
        "description": "The refund ID remains stable throughout review, provider execution, and economics updates. Its public version advances as these change."
      },
      "EventChannelConfirmation": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The public resource identifier."
          },
          "order_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "The platform order ID. Your business order reference is external_order_id."
          },
          "status": {
            "type": "string",
            "enum": [
              "awaiting_attestation",
              "pending",
              "confirmed",
              "unknown",
              "manual_review",
              "not_required"
            ],
            "description": "The business state of the resource. HTTP 202 alone does not indicate completion."
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "The current resource version used for concurrency control."
          }
        },
        "required": [
          "id",
          "order_id",
          "status",
          "version"
        ]
      },
      "listAppsResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/App"
            },
            "maxItems": 100
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "data",
          "meta",
          "next_cursor"
        ]
      },
      "getAppResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/App"
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        },
        "required": [
          "data",
          "meta"
        ]
      },
      "listOrdersResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Order"
            },
            "maxItems": 100
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "data",
          "meta",
          "next_cursor"
        ]
      },
      "getOrderResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Order"
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        },
        "required": [
          "data",
          "meta"
        ]
      },
      "listRefundsResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Refund"
            },
            "maxItems": 100
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "data",
          "meta",
          "next_cursor"
        ]
      },
      "getRefundResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Refund"
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        },
        "required": [
          "data",
          "meta"
        ]
      },
      "getRefundEligibilityResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/RefundEligibility"
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        },
        "required": [
          "data",
          "meta"
        ]
      },
      "createRefundResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Refund"
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        },
        "required": [
          "data",
          "meta"
        ]
      },
      "getBalanceResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Balance"
            },
            "maxItems": 100
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "data",
          "meta",
          "next_cursor"
        ]
      },
      "listReleaseStagesResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ReleaseStage"
            },
            "maxItems": 100
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "data",
          "meta",
          "next_cursor"
        ]
      },
      "getOperationResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Operation"
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        },
        "required": [
          "data",
          "meta"
        ]
      }
    }
  }
}
