Skip to main content

Settlement and Funding Files: Formats, Parsing and Validation

Last Updated: 2026-12-01 Status: Complete

A settlement file is a batch data file in which an acquirer, processor or bank reports the transactions, fees and funds that make up a settlement or funding cycle. Reconciliation is only as reliable as the ingestion of these files, so this page shows what file types you will receive, what formats they use, and how to build a pipeline that lands, validates, quarantines, loads and publishes them safely. It ends with a NestJS-style parser sketch for a fixed-width record.

Quick Reference​

  • Expect five file families: transaction detail, fee and interchange detail, funding or deposit summary, chargeback and adjustment, and network reports.
  • Formats vary by provider: fixed-width, CSV, XML, plus bank-side ISO 20022 camt.053/camt.054 and BAI2.
  • Delivery is usually SFTP with PGP encryption, or an API.
  • Always validate header and trailer control totals before trusting file contents.
  • Files may contain full PANs: tokenize or truncate at ingest, and restrict access.

What Files Does an Acquirer or PayFac Receive?​

File typeContentUsed for
Transaction-level settlement detailOne record per cleared sale or credit: IDs, amounts, dates, merchant, card brand, entry modeLeg 2 of reconciliation; matching to your ledger
Fee and interchange detailInterchange category, interchange amount, assessments, processor fees per transaction or aggregateFee reconciliation and downgrade analysis
Funding file or deposit summaryFunding date, gross, deductions, net amount, destination accountMatching to bank deposits
Chargeback and adjustment filesDisputes, representments, fee collections, prior-period adjustmentsUnexpected deductions; see Chargebacks
Network reportsNetwork settlement and activity summaries (such as positions by settlement date)Proof of network-level totals

Names, layouts and cut times differ by provider; the specification from your processor is the source of truth.

Which File Formats Are Used?​

FormatDefinitionTypical useEngineering notes
Fixed-widthEach field occupies a defined column range; records have a record typeLegacy processor and mainframe-origin filesParse by byte offset, watch character encoding and signed or implied-decimal amounts
CSVDelimited text, usually with a header rowMany processor portals and reportsHandle quoting, embedded delimiters and locale-specific decimals
XMLHierarchical markup with a schemaModern processor and bank filesValidate against XSD where provided; stream large files
ISO 20022 camt.053Bank-to-customer statement (end-of-day account activity) in XMLBank deposits, balancesContains booked entries, opening and closing balance
ISO 20022 camt.054Bank-to-customer debit/credit notificationIntraday notices of individual credits or debitsOften earlier than the statement; do not double count
BAI2A US bank reporting format of comma-separated records with account, balance and transaction detail codesBank balance and transaction reportingRecords are continued with continuation records; amounts are in minor units without decimal point
Amount Representation

Never parse monetary amounts as floating point numbers. Convert to integer minor units (or a decimal library), and record the currency exponent explicitly. Many fixed-width files use implied decimals and a trailing sign.

How Are Files Delivered and Protected?​

  • SFTP with PGP. The provider drops files on an SFTP server, usually encrypted with PGP. Use key-based SSH authentication, restrict by IP where possible, and keep keys in a secrets manager, never in code or configuration files. Plan key rotation: support more than one active decryption key during rotation, record the key identifier used per file, and test the rotation in a lower environment.
  • API delivery. Some providers expose reports through authenticated APIs or webhooks announcing availability. Treat the announcement as a hint and still fetch and validate the file.
  • Authentication and access. Require MFA for human access to file stores, and apply least privilege to service accounts.
  • PCI DSS. Files can contain full PANs. Apply the controls described in Tokenization: tokenize or truncate at ingest, never write PANs to logs, store the original PGP-encrypted file in access-controlled storage with a defined retention and purge schedule, and decrypt only inside the restricted ingest service. Confirm scope with your QSA.

How to Design a Settlement File Ingestion Pipeline​

  1. Land the raw file. Store the original PGP-encrypted file in access-controlled storage with a defined retention and purge schedule, and decrypt only inside the restricted ingest service. Keeping the original lets you replay and audit. Record file name, size, received time and key identifier.
  2. Checksum and duplicate-file detection. Compute a SHA-256 hash and compare it, together with the provider's file identifier or sequence number, to files already received. Providers sometimes resend a file with the same name and different content; treat a same-id, different-hash file as an incident to investigate rather than overwriting.
  3. Header and trailer control totals. Verify the record count and hash or amount totals declared in the trailer against what you actually read. A mismatch usually means truncation.
  4. Schema and record validation. Check record types, required fields, numeric formats, date validity, currency codes and known enumerations.
  5. Quarantine without blocking. Where safe, write invalid records to a quarantine table with the reason and continue loading valid ones. Block the whole file when the failure is structural (bad header, count mismatch) or when partial loading would give misleading control totals. Reconcile quarantined amounts into the file total so nothing disappears.
  6. Idempotent load. Key each row by file id plus record sequence, with a unique constraint, so that a retried job cannot insert duplicates. See Idempotency in Payments for the principle.
  7. Publish events. Emit a file-loaded event (file id, type, business date, totals, quarantine count) to trigger reconciliation. Module 5 will cover event-driven design and webhooks in more depth.

How to Handle Late or Missing Files​

Maintain an expected-file schedule: for each provider, file type and business date, the expected arrival window, derived from the specification and observed history. A scheduler creates an expectation record daily, and the ingestion pipeline fulfils it.

Consider the scenario in which a funding file is expected at 2:00 am and is not present at 3:00 am:

StepAction
1At the expected time plus a grace period, the expectation moves to "late" and a low-severity alert is raised
2Check the provider's status page, SFTP connectivity, key validity and whether a holiday calendar applies
3Downstream jobs that depend on the file (for example auto-reconciliation and merchant payout approval) are held, not run on partial data
4If the file remains missing past the second threshold, escalate to the provider contact and operations lead
5On arrival, process normally, mark the expectation fulfilled and record the lateness for SLA tracking
6Never let payouts depend on an assumed file content; payouts should rely on validated, loaded data

Alerts should also cover the inverse: a file that arrives but is unusually small or large compared with history, which is a signal of a partial or duplicated extract.

NestJS-Style Parser and Validator Sketch​

The following sketch parses an illustrative fixed-width detail record. The layout is invented for teaching; use your provider's specification. Sensitive fields are tokenized immediately and never logged.

import { Injectable, Logger } from '@nestjs/common';

export enum RecordType {
Header = 'H',
Detail = 'D',
Trailer = 'T',
}

export interface SettlementDetail {
fileId: string;
sequence: number;
networkTransactionId: string;
authCode: string;
amountMinor: bigint; // integer minor units
currency: string; // ISO 4217 alphabetic code
entryDate: string; // YYYY-MM-DD
accountToken: string; // token, never the PAN
last4: string;
}

export class RecordError extends Error {
constructor(public readonly sequence: number, message: string) {
super(message);
}
}

// Illustrative layout (0-based start, length):
// type(0,1) txnId(1,15) auth(16,6) amount(22,12) sign(34,1)
// currency(35,3) date(38,8) pan(46,19)
@Injectable()
export class SettlementDetailParser {
private readonly logger = new Logger(SettlementDetailParser.name);

constructor(private readonly tokenVault: { tokenize(pan: string): Promise<string> }) {}

async parse(fileId: string, sequence: number, line: string): Promise<SettlementDetail> {
if (line.length < 65) {
throw new RecordError(sequence, 'record too short');
}
if (line[0] !== RecordType.Detail) {
throw new RecordError(sequence, 'unexpected record type');
}

const amountDigits = line.substring(22, 34);
if (!/^\d{12}$/.test(amountDigits)) {
throw new RecordError(sequence, 'amount is not numeric');
}
const sign = line[34] === '-' ? -1n : 1n;

const currency = line.substring(35, 38);
if (!/^[A-Z]{3}$/.test(currency)) {
throw new RecordError(sequence, 'invalid currency');
}

const date = line.substring(38, 46);
const entryDate = `${date.slice(0, 4)}-${date.slice(4, 6)}-${date.slice(6, 8)}`;
if (Number.isNaN(Date.parse(entryDate))) {
throw new RecordError(sequence, 'invalid date');
}

const pan = line.substring(46, 65).trim();
const accountToken = await this.tokenVault.tokenize(pan); // never log pan
const last4 = pan.slice(-4);

return {
fileId,
sequence,
networkTransactionId: line.substring(1, 16).trim(),
authCode: line.substring(16, 22).trim(),
amountMinor: sign * BigInt(amountDigits),
currency,
entryDate,
accountToken,
last4,
};
}
}

export interface FileTrailer {
recordCount: number;
amountTotalMinor: bigint;
}

export function validateTrailer(
details: SettlementDetail[],
quarantinedCount: number,
quarantinedAmountMinor: bigint,
trailer: FileTrailer,
): void {
const count = details.length + quarantinedCount;
const total =
details.reduce((sum, d) => sum + d.amountMinor, 0n) + quarantinedAmountMinor;
if (count !== trailer.recordCount || total !== trailer.amountTotalMinor) {
throw new Error('Trailer control totals do not match; reject file');
}
}

Points to note: quarantined records still count toward trailer totals; the persistence layer should enforce a unique key on file id and sequence; and the parser handles card data only long enough to tokenize it, so the surrounding service should run in a restricted network segment.

Time-Sensitive

File layouts, delivery methods and cut times are provider-specific and change with processor migrations. Confirm every layout against the current provider specification, and review PGP and SSH key lifetimes regularly. Compliance questions about handling PAN data should go to your CISO or QSA.

References​

Share: