Server SDK
@trivio.ink/node Quick Start
Server-side client management and crash-free JSON ledger records for backend services.
Installation
npm install @trivio.ink/node @trivio.ink/coreUsing TrivioClient
In server environments, instantiate a singleton TrivioClient with your pre-loaded fee rules and settlement policies:
server-client.tstypescript
import { TrivioClient } from "@trivio.ink/node";
// 1. Initialize client with pre-configured rules and policies
const client = new TrivioClient({
feeRules: [
{
id: "RULE_MERCHANT_PRIMARY",
version: "1.0.0",
priority: 10,
acquirerId: "ACQ_STRIPE",
currency: "USD",
effectiveFrom: "2026-01-01",
rateSource: "merchant_configured",
feeStructure: {
rateBasisPoints: 290, // 2.90%
fixedFeeMinor: 30, // $0.30
},
},
],
settlementPolicies: [
{
id: "POL_STANDARD_T2",
version: "1.0.0",
acquirerId: "ACQ_STRIPE",
currency: "USD",
effectiveFrom: "2026-01-01",
cycleLength: 2,
cycleUnit: "business_days",
cutOffTime: "17:00:00",
timeZone: "America/New_York",
calendarId: "CAL_US_FED",
},
],
calendars: [
{
id: "CAL_US_FED",
version: "2026.1",
timeZone: "America/New_York",
workingDays: [1, 2, 3, 4, 5],
holidays: ["2026-12-25", "2027-01-01"],
},
],
});
// 2. Compute settlement for an incoming payment transaction
const estimate = client.calculatePaymentSettlementEstimate({
grossMinor: 10000, // $100.00
currency: "USD",
transactionTime: "2026-11-16T12:00:00Z",
acquirerId: "ACQ_STRIPE",
});
console.log("Estimated Net:", estimate.netMinor); // 9680 ($96.80)Crash-Free BigInt JSON Serialization
JavaScript standard JSON.stringify throws a TypeError: Do not know how to serialize a BigInt when encountering raw BigInt fields.
The Node SDK includes built-in ledger snapshot serializers that convert integer minor units safely for database and API transmission without crashing.
