Documentation menu

SDKs & tools

Generate CBE payment QR codes in TypeScript.

@creofam/veritas-qr builds CBE-compatible EMV payment payloads and renders QR images locally in your application. Use it to make CBE checkout faster, then verify the buyer's payment reference with Veritas.

Install

bash
pnpm add @creofam/veritas-qr

The package supports Node.js 18 or newer and includes TypeScript declarations. View it on npm or inspect the source repository.

Build and render a QR

Supply the CBE account holder name and account number. Add an amount and purpose for a fixed checkout payment, or omit the amount for a reusable account QR.

typescript
import {
  buildCbePayload,
  createCbeQrDataUrl,
  createCbeQrSvg,
} from "@creofam/veritas-qr";

const payment = {
  name: "Veritas Cafe",
  account: "1000123456789",
  amount: "850.00",
  additionalData: {
    purpose: "Order 1842",
  },
};

const emvPayload = buildCbePayload(payment);
const svg = await createCbeQrSvg(payment, { width: 280 });
const dataUrl = await createCbeQrDataUrl(payment, { width: 280 });

Generate it on the server

Keep payout account details in server-side environment variables and return the generated SVG to your checkout UI.

typescript
import { createCbeQrSvg } from "@creofam/veritas-qr";
import { NextResponse } from "next/server";

export async function POST(request: Request) {
  const { amount, orderId } = await request.json() as {
    amount: string;
    orderId: string;
  };

  const svg = await createCbeQrSvg({
    name: process.env.CBE_ACCOUNT_NAME!,
    account: process.env.CBE_ACCOUNT_NUMBER!,
    amount,
    additionalData: { purpose: `Order ${orderId}` },
  });

  return NextResponse.json({ svg });
}

Verify after payment

A QR prefills payment details; it does not prove that money was transferred. Ask the buyer for the resulting CBE reference and confirm it through the relevant Veritas verification or hosted checkout route.

typescript
const confirmation = await fetch(
  `${process.env.VERITAS_API_URL ?? "https://verifyapi.leulzenebe.pro"}/payment-links/${paymentLinkId}/confirm`,
  {
    method: "POST",
    headers: { "content-type": "application/json" },
    body: JSON.stringify({
      provider: "cbe",
      reference: buyerSubmittedReference,
      buyerName: "Betty",
      buyerEmail: "[email protected]",
    }),
  },
);

const result = await confirmation.json();
if (!confirmation.ok || result.success === false) {
  throw new Error(result.error ?? "CBE payment was not confirmed");
}