Skip to content

Treasury ​

zr.treasury covers COD settlement — balance, transaction stats, payments, and their transactions.

Balance ​

ts
const balance = await zr.treasury.getBalance();

Read the balance defensively

The live balance shape differs from the spec (drift §9.3). The GetSupplierStatsAmountResponse type is the union of both; live responses include totalAmountPaid, totalAmountReadyToBePaid, totalAmountDelivered, totalAmountNotReadyCashed, totalAmountReadyToBeCashed — read fields defensively.

Transaction stats ​

ts
const stats = await zr.treasury.getTransactionsStats();

Payments ​

ts
const page = await zr.treasury.searchPayments({ pageSize: 20, orderBy: ['createdAt desc'] });
for await (const p of zr.treasury.searchPaymentsAll({ pageSize: 100 })) { /* … */ }

// get one payment with details — POST-by-id with an options body:
const payment = await zr.treasury.getPayment(paymentId);

// a payment's treasury transactions:
const txns = await zr.treasury.searchPaymentTransactions(paymentId, { pageSize: 50 });

Export ​

ts
const reportId = await zr.treasury.exportPayments({ /* … */ }); // returns a report id (UUID)

Poll zr.reports for the report, then download it.

Accepting a payment ​

ts
await zr.treasury.acceptPayment(supplierPaymentId, { /* AcceptSupplierPaymentRequest */ });

A real settlement event

acceptPayment is a PUT that settles money. It is a real financial action — never call it "to see what happens". (The Playground deliberately exposes no accept-payment route.)

Released under the MIT License. Not affiliated with ZR Express.