{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/origin-energy/main/json-schema/origin-energy-legacy-payment-instruction-schema.json",
  "title": "LegacyPaymentInstruction",
  "x-generated": "2026-10-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/origin-energy-post-account-import-api-openapi.yml#/components/schemas/LegacyPaymentInstruction",
  "type": "object",
  "properties": {
    "external_account_number": {
      "type": "string",
      "description": "<p>The account number in the source system. This, along with the <code>import_supplier</code>, will be used to find the account in Kraken.</p>"
    },
    "import_supplier": {
      "enum": [
        "ORIGIN_SOLARFLEX_INACTIVE",
        "ORIGIN",
        "WIN_CONNECT_PARENT",
        "ORIGIN_CNI",
        "ORIGIN_BUSINESS",
        "WIN_CONNECT",
        "ORIGIN_SOLARFLEX",
        "ORIGIN_BUSINESS_NO_CONTRACT"
      ],
      "type": "string",
      "x-spec-enum-id": "9572ea198e3a9787",
      "description": "<p>The import supplier code that the account was imported on to. This, along with the <code>external_account_number</code>, will be used to find the account in Kraken.</p>",
      "x-enum-descriptions": {
        "ORIGIN_SOLARFLEX_INACTIVE": "Origin SolarFlex Inactive",
        "ORIGIN": "Origin",
        "WIN_CONNECT_PARENT": "Win Connect Parent",
        "ORIGIN_CNI": "Origin CNI",
        "ORIGIN_BUSINESS": "Origin Zero Business Import Supplier",
        "WIN_CONNECT": "WinConnect",
        "ORIGIN_SOLARFLEX": "Origin SolarFlex",
        "ORIGIN_BUSINESS_NO_CONTRACT": "Origin Business - No Contracts e.g. trustee"
      }
    },
    "instruction_reference": {
      "type": "string",
      "description": "<p>The reference of the mandate as known by the vendor.</p>",
      "deprecated": true,
      "x-use-instead": "reference",
      "maxLength": 128
    },
    "ledger_code": {
      "type": "string",
      "description": "<p>The code of the relevant Kraken ledger type for the payment instruction. This code must exist in Kraken.</p>",
      "x-validators": [
        {
          "name": "Validate ledger code",
          "description": "Validates that the ledger code provided in the payload matches an available ledger type in Kraken.",
          "possible_errors": [
            "ledger_code_does_not_exist"
          ]
        }
      ]
    },
    "reference": {
      "type": "string",
      "description": "<p>The reference of the mandate as known by the vendor.</p>",
      "maxLength": 512
    },
    "type": {
      "enum": [
        "BPAY",
        "CARD",
        "CUSTOM",
        "DIRECT_DEBIT",
        "GMO_REFUND",
        "PAYMENT_SLIP"
      ],
      "type": "string",
      "x-spec-enum-id": "601d0b035869d4dd",
      "description": "<p>The payment type of the payment instruction.</p>",
      "x-enum-descriptions": {
        "BPAY": "BPAY",
        "CARD": "Card",
        "CUSTOM": "Custom",
        "DIRECT_DEBIT": "Direct Debit",
        "GMO_REFUND": "GMO Refund",
        "PAYMENT_SLIP": "Payment slip"
      }
    },
    "use_for_scheduled_payments": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "<p>Whether this payment instruction should be used for scheduled payments on a given ledger. If true, this instruction will be set as the payment method for the account's payment schedule.</p>"
    },
    "valid_from": {
      "type": [
        "string",
        "null"
      ],
      "format": "date",
      "description": "<p>The date from which the payment instruction is valid.</p>"
    },
    "vendor": {
      "enum": [
        "WESTPAC"
      ],
      "type": "string",
      "x-spec-enum-id": "19baa89b6ef9d00c",
      "description": "<p>The vendor for the payment instruction.</p>",
      "x-enum-descriptions": {
        "WESTPAC": "Westpac"
      }
    }
  },
  "required": [
    "external_account_number",
    "import_supplier",
    "type",
    "vendor"
  ],
  "x-validators": [
    {
      "name": "Validate that account data is staged and account created",
      "description": "Validate that an account exists for the <code>external_account_number</code> and <code>import_supplier</code> code. This means that the import data must already have been staged and processed into an account.",
      "possible_errors": [
        "account_not_found",
        "import_process_does_not_exist"
      ]
    },
    {
      "name": "Validate that migration is ongoing",
      "description": "Validate whether or not an import supplier is open for further data migration.",
      "possible_errors": [
        "import_supplier_migration_not_ongoing"
      ]
    },
    {
      "name": "Validate that either <code>⁨instruction_reference⁩</code> or <code>⁨reference⁩</code> are provided",
      "description": "Validate that exactly one of <code>⁨instruction_reference⁩</code> or <code>⁨reference⁩</code> is provided.",
      "possible_errors": [
        "mutually_exclusive_field_required"
      ]
    }
  ]
}