Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Pratyay360/upiqrcode/llms.txt

Use this file to discover all available pages before exploring further.

The upiqrcode package ships TypeScript types generated directly from the Rust/WebAssembly source via wasm_bindgen. You can import the interfaces alongside the functions to get full type safety in TypeScript projects. Every type described on this page matches the definitions in the compiled .d.ts output exactly.

Import syntax

import init, { upiqrcode, svg_qr_code, type UpiqrcodeParams, type UpiqrcodeResult } from 'upiqrcode';

UpiqrcodeParams

UpiqrcodeParams describes the object you pass to upiqrcode(). All fields are optional at the type level, but payeeVPA and payeeName are validated at runtime and will cause the Promise to reject if they are missing or too short.
export interface UpiqrcodeParams {
  payeeVPA?: string;
  payeeName?: string;
  payeeMerchantCode?: string;
  transactionId?: string;
  transactionRef?: string;
  transactionNote?: string;
  amount?: string;
  minimumAmount?: string;
  currency?: string;
  transactionRefUrl?: string;
}
payeeVPA
string
UPI Virtual Payment Address (e.g. merchant@upi). Required at runtime. Minimum 5 characters.
payeeName
string
Display name of the payee shown in payment apps. Required at runtime. Minimum 4 characters.
amount
string
Transaction amount as a decimal string (e.g. "100.00"). If omitted, the payer selects the amount.
minimumAmount
string
Minimum acceptable payment amount. Maps to the mam UPI parameter.
currency
string
ISO 4217 currency code (e.g. "INR"). If omitted, the cu parameter is excluded from the intent URL; most UPI apps treat the currency as INR when it is absent.
transactionId
string
Unique transaction identifier generated by your system. Maps to the tid UPI parameter.
transactionRef
string
Merchant-side reference number for the transaction. Maps to the tr UPI parameter.
transactionNote
string
Human-readable note or description visible to the payer. Maps to the tn UPI parameter.
payeeMerchantCode
string
Merchant category code assigned to your business. Maps to the me UPI parameter.
transactionRefUrl
string
Reference URL associated with the transaction. Maps to the url UPI parameter.

UpiqrcodeResult

UpiqrcodeResult describes the object resolved by upiqrcode() on success.
export interface UpiqrcodeResult {
  qr: string;
  intent: string;
}
qr
string
required
SVG markup string of the generated QR code (minimum 200×200 px). Inject this into the DOM using innerHTML or, in React, with dangerouslySetInnerHTML={{ __html: result.qr }}.
intent
string
required
The full UPI intent URL (e.g. upi://pay?pa=merchant@upi&pn=Acme+Store&am=100.00&cu=INR) that was encoded in the QR code. Use this as the href of a deep-link button so mobile users can open their payment app directly.

init()

init() loads the WebAssembly binary that powers the library. You must call and await it once before invoking upiqrcode() or svg_qr_code(). Calling it more than once per page load is safe but unnecessary.
import init from 'upiqrcode';

await init();
Call init() at application startup or at the top of any async function that uses the library, before the first call to upiqrcode() or svg_qr_code(). You only need to call it once per page load.

Complete import example

import init, {
  upiqrcode,
  svg_qr_code,
  type UpiqrcodeParams,
  type UpiqrcodeResult,
} from 'upiqrcode';

async function setup() {
  await init();

  const params: UpiqrcodeParams = {
    payeeVPA: 'merchant@upi',
    payeeName: 'Acme Store',
    amount: '99.00',
    currency: 'INR',
    transactionNote: 'Subscription renewal',
  };

  const result: UpiqrcodeResult = await upiqrcode(params);

  document.getElementById('qr')!.innerHTML = result.qr;
  console.log('Intent URL:', result.intent);
}

Build docs developers (and LLMs) love