diff --git a/src/index.ts b/src/index.ts index f63176c..3ef2831 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,6 +35,10 @@ export interface VerifyRequest { receiverName: string; /** Required for CBE and Bank of Abyssinia. Ignored for other providers. */ receiverAccount?: string; + /** Overrides the saved underpayment limit for this call: "25" = 25 ETB, "1%" = one percent. */ + tolerance?: string; + /** Overrides the saved receipt age limit for this call, in hours. 0 disables it for this call. */ + maxAgeHours?: number; } export interface VerifyResult { @@ -86,6 +90,8 @@ export interface VerifyResult { * about who received the money. */ receiver_source: 'settings' | 'request' | 'none' | null; + /** Same failure, written for the CUSTOMER. Show this to the payer, not `error`. */ + payer_error: string | null; /** Only present on sandbox (`TEST-…`) responses. */ sandbox?: boolean; } @@ -104,6 +110,7 @@ function normalise(r: Partial & { verified?: boolean }): VerifyRes retryable: Boolean(r.retryable), code: r.code ?? null, receiver_source: r.receiver_source ?? null, + payer_error: r.payer_error ?? null, ...(r.sandbox ? { sandbox: true } : {}), }; } @@ -172,6 +179,8 @@ export class Qbirr { receiver_name: req.receiverName, }; if (req.receiverAccount) body.receiver_account = req.receiverAccount; + if (req.tolerance) body.tolerance = req.tolerance; + if (req.maxAgeHours !== undefined) body.max_age_hours = req.maxAgeHours; return normalise(await this.request('POST', '/api/v1/verify', body)); } @@ -197,6 +206,10 @@ export class Qbirr { amount: number; receiverName: string; receiverAccount?: string; + /** Overrides the saved underpayment limit for this call: "25" = 25 ETB, "1%" = one percent. */ + tolerance?: string; + /** Overrides the saved receipt age limit for this call, in hours. 0 disables it for this call. */ + maxAgeHours?: number; file: Buffer | Uint8Array | Blob; filename?: string; contentType?: string; @@ -206,6 +219,8 @@ export class Qbirr { form.append('amount', String(opts.amount)); form.append('receiver_name', opts.receiverName); if (opts.receiverAccount) form.append('receiver_account', opts.receiverAccount); + if (opts.tolerance) form.append('tolerance', opts.tolerance); + if (opts.maxAgeHours !== undefined) form.append('max_age_hours', String(opts.maxAgeHours)); const blob = opts.file instanceof Blob ? opts.file : new Blob([opts.file as unknown as BlobPart], { type: opts.contentType || 'application/octet-stream' });