BuildCell.Emv
0.1.2
dotnet add package BuildCell.Emv --version 0.1.2
NuGet\Install-Package BuildCell.Emv -Version 0.1.2
<PackageReference Include="BuildCell.Emv" Version="0.1.2" />
<PackageVersion Include="BuildCell.Emv" Version="0.1.2" />
<PackageReference Include="BuildCell.Emv" />
paket add BuildCell.Emv --version 0.1.2
#r "nuget: BuildCell.Emv, 0.1.2"
#:package BuildCell.Emv@0.1.2
#addin nuget:?package=BuildCell.Emv&version=0.1.2
#tool nuget:?package=BuildCell.Emv&version=0.1.2
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 aMerchantEmvobject.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 aMerchantEmvobject.
Contributing
Contributions are welcome! Please feel free to submit a pull request.
License
This project is licensed under the MIT License.
| Product | Versions 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. |
-
net7.0
- System.Data.HashFunction.CRC (>= 2.0.0)
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 |