QRCodePayload Class
Provides methods to create QR code payload strings for common content types.
public static class QRCodePayloadMethods
| Name | Description |
|---|---|
| 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.csCalendarEvent(string, DateTime, DateTime, string?, string?)
QRCodePayload.csEmail(string, string?, string?)
QRCodePayload.csGeolocation(double, double)
QRCodePayload.csMeCard(string, string?, string?, string?, string?, string?, string?, string?)
QRCodePayload.csCreates 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
lastNamestring- The contact's last name.
firstNamestring?- The contact's first name.
phonestring?- The contact's phone number.
emailstring?- The contact's email address.
organizationstring?- The contact's organization.
urlstring?- The contact's website URL.
addressstring?- The contact's address.
notestring?- A note about the contact.
Returns
string A string formatted as a MeCard payload.
OneTimePassword(OneTimePasswordType, string, string, string?, OneTimePasswordAlgorithm, int, int, long?)
QRCodePayload.csCreates 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
typeOneTimePasswordType- The OTP type (TOTP or HOTP).
secretstring- The base32-encoded shared secret.
accountNamestring- The account name (e.g., user email).
issuerstring?- The issuer name (e.g., service name).
algorithmOneTimePasswordAlgorithm- The hash algorithm. Default is SHA1.
digitsint- The number of digits in the OTP code: 6, 7 or 8 (RFC 4226). Default is 6. Google Authenticator documents only 6 and 8.
periodint- For TOTP: the time step in seconds, greater than 0. Default is 30. Ignored for HOTP.
counterlong?- 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
ArgumentOutOfRangeExceptiondigitsis not 6, 7 or 8; orperiodis not positive for TOTP; orcounteris negative for HOTP.ArgumentExceptioncounterisnullfor HOTP.
Phone(string)
QRCodePayload.csSepaPayment(string, string, decimal, string?, string?, string?, string?)
QRCodePayload.csCreates 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
beneficiaryNamestring- The name of the beneficiary (max 70 characters).
ibanstring- The IBAN of the beneficiary.
amountdecimal- The amount in EUR (0.01 to 999999999.99), a whole number of cents.
bicstring?- The BIC/SWIFT code of the beneficiary's bank.
remittanceReferencestring?- A structured remittance reference (ISO 11649). Mutually exclusive with
remittanceText. remittanceTextstring?- An unstructured remittance text (max 140 characters). Mutually exclusive with
remittanceReference. informationstring?- Beneficiary to originator information (max 70 characters).
Returns
string A string formatted as an EPC QR code payload.
Exceptions
ArgumentOutOfRangeExceptionamountis 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.csVCard(string, string?, string?, string?, string?, string?, string?, string?)
QRCodePayload.csCreates 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
lastNamestring- The contact's last name.
firstNamestring?- The contact's first name.
phonestring?- The contact's phone number.
emailstring?- The contact's email address.
organizationstring?- The contact's organization.
titlestring?- The contact's title.
urlstring?- The contact's website URL.
addressstring?- The contact's address.
Returns
string A string formatted as a vCard 3.0 payload.
Wifi(string, string?, WifiAuthentication, bool)
QRCodePayload.csCreates a WiFi network configuration payload.
public static string Wifi(string ssid, string? password = null, WifiAuthentication authentication = WifiAuthentication.WPA, bool hidden = false)Parameters
ssidstring- The network SSID.
passwordstring?- The network password. Can be null for open networks.
authenticationWifiAuthentication- The authentication type.
hiddenbool- Whether the network is hidden.
Returns
string A string formatted as a WiFi QR code payload.