Crate ethqr_gen

Crate ethqr_gen 

Source
Expand description

§ethqr-gen

A Rust library for generating EMVCo-compliant QR codes for payments according to the Ethiopian Interoperable QR Standard.

§Features

  • EMVCo QR Code standard compliance
  • Support for multiple payment schemes (Visa, Mastercard, IPS ET, etc.)
  • Static and dynamic QR code generation
  • QR code image generation (with qr-image feature)

§Quick Start

§Static QR Code (no predefined amount)

use ethqr_gen::{QRBuilder, fields::SchemeConfig};

let qr_code = QRBuilder::new()
    .merchant_name("Coffee Shop")
    .merchant_city("Addis Ababa")
    .merchant_category_code("5812") // Restaurant
    .add_scheme(SchemeConfig::visa("4111111111111111"))
    .build()?;

§Dynamic QR Code (with specific amount)

use ethqr_gen::{QRBuilder, fields::{SchemeConfig, AdditionalData}};

let additional_data = AdditionalData::new()
    .bill_number("INV-001")
    .reference_label("ORDER-123");

let qr_code = QRBuilder::new()
    .merchant_name("Restaurant")
    .merchant_city("Dire Dawa")
    .merchant_category_code("5812")
    .add_scheme(SchemeConfig::ips_et(
        "581b314e257f41bfbbdc6384daa31d16",
        "CBETETAA",
        "10000171234567890",
    ))
    .transaction_amount("50.00")
    .additional_data(additional_data)
    .build()?;

§QR Code Image Generation (requires qr-image feature)

use ethqr_gen::{QRBuilder, fields::SchemeConfig};

let qr_image = QRBuilder::new()
    .merchant_name("Coffee Shop")
    .merchant_city("Addis Ababa")
    .merchant_category_code("5812")
    .add_scheme(SchemeConfig::visa("4111111111111111"))
    .build_image()?;

// Save to file
qr_image.save("/tmp/payment_qr.png")?;

§Payment Schemes

The library supports multiple payment schemes through the SchemeConfig type:

  • Visa: SchemeConfig::visa("account_info")
  • Mastercard: SchemeConfig::mastercard("account_info")
  • Unionpay: SchemeConfig::unionpay("account_info")
  • IPS ET: SchemeConfig::ips_et("guid", "bic", "account_info") (Ethiopian Interbank Payment System)

Modules§

constants
crc
error
fields
tags

Structs§

EMVTag
Represents an EMV tag with ID, length, and value
QRBuilder
Builder for constructing QR codes