npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sepa-qr-code

v1.1.0

Published

A TypeScript library for generating SEPA/EPC QR Codes

Downloads

150

Readme

EPC/SEPA QR Generator

A TypeScript library for generating EPC/SEPA (Single Euro Payments Area) QR Codes for easy bank transfers.

SEPA QR Generator API Documentation

Table of Contents

  1. Installation
  2. Usage
  3. API Reference

Installation

npm install sepa-qr-code

Usage

import { SEPAQRGenerator, SEPAData } from "sepa-qr-code";

const generator = new SEPAQRGenerator();

const data: SEPAData = {
  name: "John Doe",
  iban: "DE89370400440532013000",
  amount: "100.00",
  currency: "EUR",
  remittanceInfo: "Invoice 123",
};

generator
  .generateQRCode(data)
  .then((qrCode) => {
    console.log("QR Code generated:", qrCode);
  })
  .catch((error) => {
    console.error("Error generating QR code:", error.message);
  });

API Reference

SEPAQRGenerator

The main class for generating SEPA QR codes.

Constructor

constructor(options?: SEPAQROptions)

Creates a new instance of SEPAQRGenerator.

  • options: Optional. An object of type SEPAQROptions to customize the QR code generation.

Methods

generateQRCode
generateQRCode(data: SEPAData, outputType: OutputType = 'base64'): Promise<string | Buffer>

Generates a QR code based on the provided SEPA data.

  • data: An object of type SEPAData containing the SEPA transfer information.
  • outputType: Optional. Specifies the output format of the QR code. Default is 'base64'.
  • Returns: A Promise that resolves to either a string (for 'base64' and 'utf8' types) or a Buffer (for 'buffer' type).

SEPAData

An interface representing the data required for a SEPA transfer.

interface SEPAData {
  bic?: string;
  name: string;
  iban: string;
  amount?: string;
  currency?: string;
  purposeCode?: string;
  remittanceInfo?: string;
  beneficiaryToOriginator?: string;
}
  • bic: Optional. The Bank Identifier Code (8 or 11 characters).
  • name: Required. The name of the beneficiary (max 70 characters).
  • iban: Required. The International Bank Account Number (15 to 34 characters).
  • amount: Optional. The transfer amount (max 12 characters, including 2 decimal places).
  • currency: Optional. The currency code (3 characters, default is 'EUR').
  • purposeCode: Optional. The purpose of the credit transfer (4 characters).
  • remittanceInfo: Optional. Remittance information/Payment Reference (max 140 characters). This can be used to include additional information such as an order number.
  • beneficiaryToOriginator: Optional. Information from the beneficiary to the originator (max 70 characters).

SEPAQROptions

An interface for customizing the QR code generation.

interface SEPAQROptions {
  errorCorrectionLevel?: "L" | "M" | "Q" | "H";
  margin?: number;
  scale?: number;
}
  • errorCorrectionLevel: Optional. The error correction level of the QR Code.
    • 'L': Low (7% of codewords can be restored)
    • 'M': Medium (15% of codewords can be restored)
    • 'Q': Quartile (25% of codewords can be restored)
    • 'H': High (30% of codewords can be restored) Default is 'M'.
  • margin: Optional. The margin around the QR code in modules. Default is 4.
  • scale: Optional. The scale factor for the QR code. Default is 4.

OutputType

A type representing the possible output formats for the QR code.

type OutputType = "base64" | "buffer" | "utf8";
  • 'base64': Returns the QR code as a base64 encoded string.
  • 'buffer': Returns the QR code as a Buffer object.
  • 'utf8': Returns the raw content of the QR code as a UTF-8 string.