{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/benjipays-com/json-schema/benjipays-com-retry-charge-accounting-response-schema.json",
  "title": "RetryChargeAccountingResponse",
  "description": "Retry accounting writeback response",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/benjipays-com-transactions-api-openapi.yml#/components/schemas/RetryChargeAccountingResponse",
  "type": "object",
  "properties": {
    "data": {
      "$ref": "#/$defs/Transaction"
    },
    "meta": {
      "type": "object",
      "properties": {
        "effects": {
          "type": "object",
          "properties": {
            "accounting": {
              "$ref": "#/$defs/TransactionEffectResult"
            }
          },
          "required": [
            "accounting"
          ],
          "additionalProperties": false,
          "description": "Accounting writeback outcome for this retry (no charge, no receipt)"
        }
      },
      "required": [
        "effects"
      ],
      "additionalProperties": false,
      "description": "Retry-accounting response metadata"
    }
  },
  "required": [
    "data",
    "meta"
  ],
  "additionalProperties": false,
  "$defs": {
    "PaymentAllocation": {
      "type": "object",
      "properties": {
        "invoiceId": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Accounting invoice ID"
        },
        "amount": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "description": "Amount applied to this invoice, rounded to 2 decimal places"
        },
        "invoiceNumber": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Accounting invoice number"
        },
        "currency": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Invoice currency"
        },
        "installmentDateId": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Installment plan date identifier"
        },
        "installmentDate": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Installment due date"
        },
        "installmentAmount": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "description": "Installment amount, rounded to 2 decimal places"
        },
        "date": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Invoice date (YYYY-MM-DD)"
        }
      },
      "required": [
        "invoiceId",
        "amount",
        "invoiceNumber",
        "currency",
        "installmentDateId",
        "installmentDate",
        "installmentAmount",
        "date"
      ],
      "additionalProperties": false,
      "description": "Invoice payment allocation"
    },
    "Transaction": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Transaction identifier (result `_id`)"
        },
        "type": {
          "description": "Transaction type (e.g. payment, void, refund, deposit)",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "amount": {
          "description": "Transaction amount (`amountChargedToCard` or `amount`), rounded to 2 decimal places",
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "surchargeRate": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "surchargeAmount": {
          "description": "Surcharge amount, rounded to 2 decimal places",
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "currency": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "approved": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ]
        },
        "status": {
          "description": "Stored status (e.g. `approved`, `declined`, `queued`, `pending`, `approved_void_pending`). `inprocess` is a list filter, not a stored value.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "paymentType": {
          "description": "e.g. cc, bank",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "details": {
          "type": "object",
          "properties": {
            "message": {
              "description": "Gateway message (card payments)",
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "maskedPan": {
              "description": "Masked card number",
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "cardType": {
              "description": "Card brand (e.g. Visa, Mastercard)",
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "receiptNumber": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "paymentRef": {
              "description": "Gateway payment reference",
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "account": {
              "description": "Masked bank account number (bank payments)",
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "additionalProperties": false,
          "description": "Payment details (legacy `details` object)"
        },
        "paymentLocation": {
          "description": "Where the payment was made. Known values: `web-app` (merchant app), `customer-portal` (customer portal), `payment-portal` (pay link / payment portal), `api` (API charge, including `POST /v2/transactions`). Null when the result has no stored `paymentLocation`.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "accountingPaymentId": {
          "description": "Accounting system payment id",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "surchargeJournalEntryId": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "surchargeJournalEntryNumber": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "transactionDate": {
          "description": "ISO date of transaction",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "integrationData": {
          "description": "External integration data (e.g. Quoter)",
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "dataId": {
                  "description": "External integration data id (e.g. Quoter quote id)",
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "integrationType": {
                  "description": "Integration source type",
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "additionalProperties": false,
              "description": "Integration payload from external sources"
            },
            {
              "type": "null"
            }
          ]
        },
        "paymentsToMake": {
          "description": "Invoice payments to apply (null for void/refund)",
          "anyOf": [
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/PaymentAllocation"
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "customerId": {
          "description": "Accounting system customer ID",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "voided": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ]
        },
        "voidTransactions": {
          "description": "Void transaction details (void type only)",
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "paymentId": {
                    "description": "Accounting payment id for the void/refund",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payments": {
                    "description": "Original invoice allocations",
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "$ref": "#/$defs/PaymentAllocation"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "paymentRefNumber": {
                    "description": "Gateway payment reference number (void only)",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false,
                "description": "Void or refund transaction detail"
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "refundTransactions": {
          "description": "Refund transaction details (refund type only)",
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "paymentId": {
                    "description": "Accounting payment id for the void/refund",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payments": {
                    "description": "Original invoice allocations",
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "$ref": "#/$defs/PaymentAllocation"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "paymentRefNumber": {
                    "description": "Gateway payment reference number (void only)",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false,
                "description": "Void or refund transaction detail"
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "dueDate": {
          "description": "Invoice due date",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "estimatedSettlementDate": {
          "description": "Estimated settlement date (Benji Payments)",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "invoiceNumber": {
          "description": "Accounting invoice number",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "invoiceId": {
          "description": "Accounting invoice ID",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "customerName": {
          "description": "Customer display name",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "result": {
          "description": "Raw result string from gateway",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "paymentSubType": {
          "description": "Payment sub-type (e.g. debit)",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "surchargeReportingAmount": {
          "description": "Surcharge amount used for reporting, rounded to 2 decimal places",
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "commissions": {
          "description": "Platform commission amount, rounded to 2 decimal places",
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "expectedSettlementAmount": {
          "description": "Expected net settlement amount, rounded to 2 decimal places",
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "gatewayId": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "gatewayProcessor": {
          "description": "e.g. benjipayments, bambora, moneris, elavon, stripe, clover",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "settlementEligible": {
          "type": "boolean",
          "description": "Whether settlement tracking applies (e.g. Benji Payments)"
        },
        "settlementStatus": {
          "type": "string",
          "enum": [
            "open",
            "complete",
            "error",
            "na"
          ],
          "description": "Derived settlement status; `na` when not settlement-eligible"
        },
        "settlementDate": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "ISO actual settlement date, or null"
        },
        "paymentApplied": {
          "description": "Whether payment was applied in accounting",
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ]
        },
        "batchRefNumber": {
          "description": "Bank batch reference number",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "id",
        "details",
        "settlementEligible",
        "settlementStatus",
        "settlementDate"
      ],
      "additionalProperties": false,
      "description": "A single payment transaction"
    },
    "TransactionEffectResult": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "succeeded",
            "voided",
            "failed",
            "skipped",
            "notified"
          ],
          "description": "Outcome of one side effect for this create-charge request. `notified` is used when a BACS/SEPA advance notice was sent and the debit is scheduled for later."
        },
        "detail": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Human-readable processing messages when present; null when there are none"
        },
        "paymentId": {
          "description": "Accounting payment id when accounting apply succeeded (accounting effect only)",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "status",
        "detail"
      ],
      "additionalProperties": false,
      "description": "Side-effect result bucket"
    }
  }
}