EmvQr 1.2.4
dotnet add package EmvQr --version 1.2.4
NuGet\Install-Package EmvQr -Version 1.2.4
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="EmvQr" Version="1.2.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EmvQr" Version="1.2.4" />
<PackageReference Include="EmvQr" />
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 EmvQr --version 1.2.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EmvQr, 1.2.4"
#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 EmvQr@1.2.4
#: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=EmvQr&version=1.2.4
#tool nuget:?package=EmvQr&version=1.2.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
EmvQr - EMVCo QR Code Library for .NET
A lightweight, dependency-free .NET library for generating and parsing EMVCo Merchant Presented QR Codes (MPM). Compliant with EMVCo QR Code Specification for Payment Systems (ISO/IEC 18004).
Features
- Builder API: Fluent interface for constructing valid EMVCo strings.
- Parser: Read and modify existing EMVCo strings.
- CRC16 Calculation: Automatic checksum generation (ISO/IEC 13239).
- Nested Data Support: Handles nested objects (e.g., Additional Data Field 62).
- Standard Tags: Built-in constants for common EMV tags.
Installation
dotnet add package EmvQr
Usage
1. Generating a QR Code
using EmvQr;
using EmvQr.Standards; // Import definitions (New in v1.2)
var builder = new EmvBuilder()
.SetPayloadFormatIndicator("01")
.SetPointOfInitiationMethod(false) // Static
// Use standard definitions for autocomplete
.SetMerchantCategoryCode(MerchantCategoryCodes.GroceryStoresSupermarkets)
.SetTransactionCurrency(Currencies.EUR)
.SetCountryCode(Countries.FR)
.SetTransactionAmount(24.99)
.SetMerchantName("Super Market")
.SetMerchantCity("Paris")
.AddMerchantAccountInformation("26", "MERCHANT_ID_123");
// ...
2. Validation (New in v1.1)
Ensure your QR Code meets the mandatory EMVCo requirements.
var qr = new EmvBuilder().Build(); // Missing fields
var parsedQr = EmvParser.Parse(qr);
var validation = EmvValidator.Validate(parsedQr);
if (!validation.IsValid)
{
foreach (var error in validation.Errors)
{
Console.WriteLine($"Error: {error}");
}
}
3. Parsing a QR Code
using EmvQr;
string rawQr = "000201010211..."; // Your EMVCo string
try
{
var qr = EmvParser.Parse(rawQr);
// Access simple data
string merchantName = qr.Get(EmvTag.MerchantName)?.Value;
string amount = qr.Get(EmvTag.TransactionAmount)?.Value;
// Access nested data (e.g., Tag 62)
var additionalData = qr.Get(EmvTag.AdditionalDataFieldTemplate);
if (additionalData != null && additionalData.IsNested)
{
var billNumber = additionalData.NestedData
.FirstOrDefault(x => x.Tag == EmvTag.BillNumber)?.Value;
}
}
catch (Exception ex)
{
Console.WriteLine("Invalid QR Code: " + ex.Message);
}
3. Validating CRC
The EmvParser reads the string as-is. To validate the checksum manually:
string rawQr = "000201...6304ABCD";
string dataWithoutCrc = rawQr.Substring(0, rawQr.Length - 4);
string providedCrc = rawQr.Substring(rawQr.Length - 4);
string calculatedCrc = Crc16.Compute(dataWithoutCrc);
if (providedCrc == calculatedCrc) {
Console.WriteLine("Valid Checksum");
}
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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.
-
net8.0
- No dependencies.
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 |
|---|---|---|
| 1.2.4 | 142 | 2/1/2026 |