QRCodePayload Class

Provides methods to create QR code payload strings for common content types.

public static class QRCodePayload

Methods

NameDescription
Bitcoin(string, decimal?, string?, string?)Creates a Bitcoin payment URI (BIP-0021 standard).
CalendarEvent(string, DateTime, DateTime, string?, string?)Creates a calendar event (VEVENT) payload.
Email(string, string?, string?)Creates an email (mailto:) payload.
Geolocation(double, double)Creates a geolocation payload.
MeCard(string, string?, string?, string?, string?, string?, string?, string?)Creates a MeCard contact payload. MeCard is a compact contact format widely supported on Android.
OneTimePassword(OneTimePasswordType, string, string, string?, OneTimePasswordAlgorithm, int, int, long?)Creates an OTP Auth URI for two-factor authentication setup. Supported by Google Authenticator, Authy, Microsoft Authenticator, and most TOTP/HOTP apps.
Phone(string)Creates a phone number (tel:) payload.
SepaPayment(string, string, decimal, string?, string?, string?, string?)Creates an EPC QR code payload for SEPA credit transfers (European Payments Council standard EPC069-12).
Sms(string, string?)Creates an SMS payload.
VCard(string, string?, string?, string?, string?, string?, string?, string?)Creates a vCard 3.0 contact payload.
Wifi(string, string?, WifiAuthentication, bool)Creates a WiFi network configuration payload.

Bitcoin(string, decimal?, string?, string?)

QRCodePayload.cs

Creates a Bitcoin payment URI (BIP-0021 standard).

public static string Bitcoin(string address, decimal? amount = null, string? label = null, string? message = null)

Parameters

address string
The Bitcoin address.
amount decimal?
The amount in BTC.
label string?
A label for the address (e.g., recipient name).
message string?
A message describing the transaction.

Returns

string A string formatted as a BIP-0021 Bitcoin URI.

CalendarEvent(string, DateTime, DateTime, string?, string?)

QRCodePayload.cs

Creates a calendar event (VEVENT) payload.

public static string CalendarEvent(string summary, DateTime start, DateTime end, string? location = null, string? description = null)

Parameters

summary string
The event summary/title.
start DateTime
The start date and time (UTC).
end DateTime
The end date and time (UTC).
location string?
The event location.
description string?
The event description.

Returns

string A string formatted as an iCalendar VEVENT.

Email(string, string?, string?)

QRCodePayload.cs

Creates an email (mailto:) payload.

public static string Email(string address, string? subject = null, string? body = null)

Parameters

address string
The email address.
subject string?
The email subject.
body string?
The email body.

Returns

string A string formatted as a mailto URI.

Geolocation(double, double)

QRCodePayload.cs

Creates a geolocation payload.

public static string Geolocation(double latitude, double longitude)

Parameters

latitude double
The latitude in decimal degrees.
longitude double
The longitude in decimal degrees.

Returns

string A string formatted as a geo URI.

MeCard(string, string?, string?, string?, string?, string?, string?, string?)

QRCodePayload.cs

Creates a MeCard contact payload. MeCard is a compact contact format widely supported on Android.

public static string MeCard(string lastName, string? firstName = null, string? phone = null, string? email = null, string? organization = null, string? url = null, string? address = null, string? note = null)

Parameters

lastName string
The contact's last name.
firstName string?
The contact's first name.
phone string?
The contact's phone number.
email string?
The contact's email address.
organization string?
The contact's organization.
url string?
The contact's website URL.
address string?
The contact's address.
note string?
A note about the contact.

Returns

string A string formatted as a MeCard payload.

OneTimePassword(OneTimePasswordType, string, string, string?, OneTimePasswordAlgorithm, int, int, long?)

QRCodePayload.cs

Creates an OTP Auth URI for two-factor authentication setup. Supported by Google Authenticator, Authy, Microsoft Authenticator, and most TOTP/HOTP apps.

public static string OneTimePassword(OneTimePasswordType type, string secret, string accountName, string? issuer = null, OneTimePasswordAlgorithm algorithm = OneTimePasswordAlgorithm.SHA1, int digits = 6, int period = 30, long? counter = null)

Parameters

type OneTimePasswordType
The OTP type (TOTP or HOTP).
secret string
The base32-encoded shared secret.
accountName string
The account name (e.g., user email).
issuer string?
The issuer name (e.g., service name).
algorithm OneTimePasswordAlgorithm
The hash algorithm. Default is SHA1.
digits int
The number of digits in the OTP code: 6, 7 or 8 (RFC 4226). Default is 6. Google Authenticator documents only 6 and 8.
period int
For TOTP: the time step in seconds, greater than 0. Default is 30. Ignored for HOTP.
counter long?
For HOTP: the initial counter value, required and greater than or equal to 0. Ignored for TOTP.

Returns

string A string formatted as an otpauth URI.

Exceptions

ArgumentOutOfRangeException
digits is not 6, 7 or 8; or period is not positive for TOTP; or counter is negative for HOTP.
ArgumentException
counter is null for HOTP.

Phone(string)

QRCodePayload.cs

Creates a phone number (tel:) payload.

public static string Phone(string number)

Parameters

number string
The phone number.

Returns

string A string formatted as a tel URI.

SepaPayment(string, string, decimal, string?, string?, string?, string?)

QRCodePayload.cs

Creates an EPC QR code payload for SEPA credit transfers (European Payments Council standard EPC069-12).

public static string SepaPayment(string beneficiaryName, string iban, decimal amount, string? bic = null, string? remittanceReference = null, string? remittanceText = null, string? information = null)

Parameters

beneficiaryName string
The name of the beneficiary (max 70 characters).
iban string
The IBAN of the beneficiary.
amount decimal
The amount in EUR (0.01 to 999999999.99), a whole number of cents.
bic string?
The BIC/SWIFT code of the beneficiary's bank.
remittanceReference string?
A structured remittance reference (ISO 11649). Mutually exclusive with remittanceText.
remittanceText string?
An unstructured remittance text (max 140 characters). Mutually exclusive with remittanceReference.
information string?
Beneficiary to originator information (max 70 characters).

Returns

string A string formatted as an EPC QR code payload.

Exceptions

ArgumentOutOfRangeException
amount is out of range or has a fraction of a cent.
ArgumentException
A value is too long or contains a control character, both remittance values are set, or the payload exceeds 331 bytes in UTF-8.

Remarks

The payload is at most 331 bytes in UTF-8, the limit of EPC069-12. The guidelines also require a symbol of version 13 at most with error correction level ErrorCorrectionLevel.M: create the QR code with QRCode.Create and its default level.

Sms(string, string?)

QRCodePayload.cs

Creates an SMS payload.

public static string Sms(string number, string? message = null)

Parameters

number string
The phone number.
message string?
The message text.

Returns

string A string formatted as an SMS payload.

VCard(string, string?, string?, string?, string?, string?, string?, string?)

QRCodePayload.cs

Creates a vCard 3.0 contact payload.

public static string VCard(string lastName, string? firstName = null, string? phone = null, string? email = null, string? organization = null, string? title = null, string? url = null, string? address = null)

Parameters

lastName string
The contact's last name.
firstName string?
The contact's first name.
phone string?
The contact's phone number.
email string?
The contact's email address.
organization string?
The contact's organization.
title string?
The contact's title.
url string?
The contact's website URL.
address string?
The contact's address.

Returns

string A string formatted as a vCard 3.0 payload.

Wifi(string, string?, WifiAuthentication, bool)

QRCodePayload.cs

Creates a WiFi network configuration payload.

public static string Wifi(string ssid, string? password = null, WifiAuthentication authentication = WifiAuthentication.WPA, bool hidden = false)

Parameters

ssid string
The network SSID.
password string?
The network password. Can be null for open networks.
authentication WifiAuthentication
The authentication type.
hidden bool
Whether the network is hidden.

Returns

string A string formatted as a WiFi QR code payload.