Skip to content

Payments ​

Every payment code is a PaymentContent with the same five questions answered, whatever the country, and a kind per standard with its own fields.

dart
void pay(Barcode barcode) {
  if (barcode.content case final PaymentContent payment) {
    print(payment.payee); // Kaffeehaus Lumen
    print(payment.account); // the IBAN, account number, UPI ID or PIX key
    print(payment.amount); // 12.50, or null when the payer enters it
    print(payment.currency); // EUR
    print(payment.reference); // the payment reference, if any
  }
}

The amount is text in the currency's main unit with a decimal point ('12.50' euros, not cents), so no cent is lost to a double. It is as the code writes it: one code says 12.5, another 12.50, so compare amounts as numbers. The currency is the ISO 4217 code, fixed by the standard for EPC (EUR), ГОСТ (RUB) and UPI (INR).

A code whose IBAN, reference or checksum is wrong is not a payment: it parses as TextContent.

The Payment template in the demo
The demo app on the web build of the package. Allow the camera, or pick a photo of a code.Open full screen

Standards ​

KindStandardPayloadChecks
EpcPaymentContentEPC069-12 SEPA credit transfer ("GiroCode")BCD\n002\n1\nSCT\n…IBAN, BIC, RF reference, amount ≤ 999 999 999.99 EUR, 331 bytes
SwissQrBillContentSwiss Payment Standards 2.3SPC\n0200\n1\n…\nEPDIBAN or QR-IBAN, creditorReference: QR reference (mod 10) or RF, structured addresses, 997 characters
GostPaymentContentГОСТ Р 56042-2014ST00012|Name=…|…account, BIC, correspondent account, INN, KPP; read in Windows-1251, UTF-8 and KOI8-R, written in UTF-8
UpiPaymentContentNPCI UPIupi://pay?pa=…UPI address, amount, INR
EmvPaymentContentEMVCo merchant-presented QR: PIX, PayNow, PromptPay, QRIS, VietQR, DuitNow and others000201…6304XXXXCRC16; built with EmvPaymentContent.pix(...)
SpaydPaymentContentShort Payment Descriptor (Czech Republic)SPD*1.0*ACC:…IBAN, BIC, symbols, CRC32 when present

PAY by square (Slovakia) is not supported yet: it is LZMA-compressed.

Create a payment code ​

dart
const epc = EpcPaymentContent(
  name: 'Kaffeehaus Lumen',
  iban: 'DE89370400440532013000',
  amount: '12.50',
  message: 'Invoice 42',
);

Widget giroCode() => BarcodeView(
  epc.toPayload(),
  writer: const BarcodeWriter(
    BarcodeFormat.qrCode,
    errorCorrection: ErrorCorrection.medium,
  ),
  width: 200,
);

validate() lists what keeps a payment from being built, such as a wrong IBAN, before toPayload() would throw: see Building content.

A Swiss QR-bill must carry the Swiss cross in the middle: BarcodeStyle.swissQrBill draws it, with the error correction the standard requires.

dart
Widget swissBill(SwissQrBillContent bill) =>
    BarcodeView(bill.toPayload(), style: BarcodeStyle.swissQrBill, width: 200);