BuildCell.Emv 0.1.2

dotnet add package BuildCell.Emv --version 0.1.2
                    
NuGet\Install-Package BuildCell.Emv -Version 0.1.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BuildCell.Emv" Version="0.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BuildCell.Emv" Version="0.1.2" />
                    
Directory.Packages.props
<PackageReference Include="BuildCell.Emv" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BuildCell.Emv --version 0.1.2
                    
#r "nuget: BuildCell.Emv, 0.1.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BuildCell.Emv@0.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BuildCell.Emv&version=0.1.2
                    
Install as a Cake Addin
#tool nuget:?package=BuildCell.Emv&version=0.1.2
                    
Install as a Cake Tool

BuildCell.Emv

This library facilitates the generation and parsing of EMV QR codes, adhering to the specifications for merchant-presented QR codes. It is a C# port of the steplix/emv-qrcps library.

Installation

Install the package from NuGet:

dotnet add package BuildCell.Emv

Merchant Module

The primary module for merchant-presented QR codes.

Usage

To create an EMV QR code payload, instantiate MerchantEmv and populate its fields.

Generating a Payload
using BuildCell.Emv.Merchant;
using BuildCell.Emv.Merchant.Contracts;

// Create a new MerchantEmv instance
var emv = new MerchantEmv();

// Set mandatory fields
emv.SetPayloadFormatIndicator("01");
emv.SetMerchantCategoryCode("5411"); // Grocery Stores, Supermarkets
emv.SetTransactionCurrency("986"); // BRL
emv.SetCountryCode("BR");
emv.SetMerchantName("My Awesome Store");
emv.SetMerchantCity("Brasilia");

// Add merchant account information
var merchantAccountInfo = new MerchantAccountInformation();
merchantAccountInfo.SetGloballyUniqueIdentifier("com.example.myapp");
merchantAccountInfo.AddContextSpecificData("01", "1234567890");
emv.AddMerchantAccountInformation("26", merchantAccountInfo);

// Generate the payload
string payload = emv.GeneratePayload();

Console.WriteLine(payload);

This will output a string that can be encoded into a QR code.

Parsing a Payload

To parse an existing EMV QR code payload, use the MerchantParser.

using BuildCell.Emv.Merchant;

string payload = "00020101021126380009com.mercadolibre011559876543210000520400005303986540510.005802BR5913My Test Store6008Brasilia62070503***6304E4A6";

var emv = MerchantParser.ToEmv(payload);

// You can now access the parsed fields
Console.WriteLine(emv.GetMerchantName()); // My Test Store

Key Classes

  • MerchantEmv: The main class representing the entire EMV QR code structure.
  • MerchantParser: Provides static methods to parse a string payload into a MerchantEmv object.
  • Tlv: Represents a Tag-Length-Value component of the EMV structure.
  • MerchantAccountInformation: Represents the merchant's account details.
  • AdditionalDataFieldTemplate: For optional additional data.
  • MerchantInformationLanguageTemplate: For language-specific merchant information.

MerchantEmv Methods

  • GeneratePayload(): Generates the complete EMV QR code string.
  • Validate(): Checks if all mandatory fields are set.
  • Set...() methods (e.g., SetMerchantName, SetTransactionAmount): Set the values for the corresponding fields.
  • Add...() methods (e.g., AddMerchantAccountInformation): Add complex data structures.

MerchantParser Methods

  • ToEmv(string payload): Parses a payload string and returns a MerchantEmv object.

Contributing

Contributions are welcome! Please feel free to submit a pull request.

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.2 168 7/31/2025