{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://api-evangelist.github.io/fis/json-schema/fis-payment-schema.json",
  "title": "FIS Payment",
  "description": "JSON Schema for a FIS payment transaction covering ACH, wire transfers, RTP, and card-based payment methods.",
  "type": "object",
  "properties": {
    "paymentId": {
      "type": "string",
      "description": "Unique payment transaction identifier"
    },
    "status": {
      "type": "string",
      "enum": ["PENDING", "SCHEDULED", "PROCESSING", "COMPLETED", "FAILED", "CANCELLED", "RETURNED"],
      "description": "Current payment status"
    },
    "amount": {
      "type": "number",
      "minimum": 0.01,
      "description": "Payment amount in the specified currency"
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$",
      "description": "ISO 4217 three-letter currency code"
    },
    "paymentMethod": {
      "type": "string",
      "enum": ["ACH", "WIRE", "RTP", "FEDNOW", "CARD"],
      "description": "Payment rail used for this transaction"
    },
    "debtorAccount": { "$ref": "#/$defs/AccountReference" },
    "creditorAccount": { "$ref": "#/$defs/AccountReference" },
    "remittanceInfo": {
      "type": "string",
      "maxLength": 140,
      "description": "Payment reference or memo visible to parties"
    },
    "executionDate": {
      "type": "string",
      "format": "date",
      "description": "Requested or actual execution date"
    },
    "completedAt": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp when payment completed settlement"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "failureReason": {
      "type": "string",
      "description": "Reason for payment failure or return"
    },
    "networkTransactionId": {
      "type": "string",
      "description": "Reference ID assigned by the payment network (IMAD, trace number, etc.)"
    },
    "priority": {
      "type": "string",
      "enum": ["NORMAL", "HIGH", "SAME_DAY"]
    }
  },
  "required": ["paymentId", "status", "amount", "currency", "paymentMethod"],
  "$defs": {
    "AccountReference": {
      "type": "object",
      "description": "Reference to a bank account",
      "properties": {
        "accountNumber": {
          "type": "string",
          "description": "Bank account number"
        },
        "routingNumber": {
          "type": "string",
          "pattern": "^\\d{9}$",
          "description": "ABA routing transit number (9 digits)"
        },
        "accountType": {
          "type": "string",
          "enum": ["CHECKING", "SAVINGS", "LOAN"]
        },
        "accountHolderName": {
          "type": "string"
        },
        "bankName": {
          "type": "string"
        },
        "swiftCode": {
          "type": "string",
          "pattern": "^[A-Z]{4}[A-Z]{2}[A-Z0-9]{2}([A-Z0-9]{3})?$",
          "description": "SWIFT/BIC code for international wires"
        },
        "iban": {
          "type": "string",
          "description": "International Bank Account Number for cross-border payments"
        }
      },
      "required": ["accountNumber", "routingNumber"]
    }
  }
}
