Data Contract

The JavaScript API is Promise-based and uses TypeScript request/result types exported by the package.

Configuration contract

interface Ecr17Config {
  host: string;
  port?: number;
  terminalId: string;
  cashRegisterId: string;
  lrcMode?: "stx" | "std" | "noext" | "stx_noext";
  keepAlive?: boolean;
  autoReconnect?: boolean;
  connectionTimeoutMs?: number;
  responseTimeoutMs?: number;
  ackTimeoutMs?: number;
  receiptDrainMs?: number;
  retryCount?: number;
  retryDelayMs?: number;
  debug?: boolean;
}

Result contract

Payment-like results normalize terminal codes into outcome while preserving raw fields such as resultCode, stan, onlineId, authCode, and errorDescription.

PaymentResult
Events
interface PaymentResult {
  outcome: "ok" | "ko" | "cardNotPresent" | "unknownTag" | "unknown";
  resultCode: string;
  pan?: string;
  authCode?: string;
  stan?: string;
  onlineId?: string;
  errorDescription?: string;
}
client.setOnProgress((event) => console.log(event.message));
client.setOnReceiptLine((line) => console.log(line.text));
client.setOnConnectionStateChange((state) => console.log(state));

Contract invariant

The core validates fixed-width request fields before sending. Invalid local input should fail before bytes reach the terminal.