Class Payments
Field validations related to Swiss Payment standards.
Inheritance
Inherited Members
Namespace: Codecrete.SwissQRBill.Generator
Assembly: Codecrete.SwissQRBill.Core.dll
Syntax
public static class Payments
Methods
| Improve this Doc View SourceCleanValue(String, out Payments.CleaningResult)
Cleans a string value to make it viable for the Swiss Payment Standards 2018.
Unsupported characters(according to Swiss Payment Standards 2018, ch. 2.4.1 and appendix D) are replaced with spaces(unsupported whitespace) or dots (all other unsupported characters). Leading and trailing whitespace is removed.
If characters beyond 0xff are detected, the string is first normalized such that letters with umlauts or accents expressed with two code points are merged into a single code point(if possible), some of which might become valid.
If the resulting strings is all white space, null
is returned.
Declaration
public static void CleanValue(string value, out Payments.CleaningResult result)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string value to clean. |
Payments.CleaningResult | result | The result to be filled with cleaned string and flag. |
CreateIso11649Reference(String)
Creates a ISO11649 creditor reference from a raw string by prefixing the string with "RF" and the modulo 97 checksum
Whitespace is removed from the reference.
Declaration
public static string CreateIso11649Reference(string rawReference)
Parameters
Type | Name | Description |
---|---|---|
System.String | rawReference | The raw reference. |
Returns
Type | Description |
---|---|
System.String | The created creditor reference. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
|
CreateQRReference(String)
Creates a QR reference from a raw string by appending the checksum digit and prepending zeros to make it the correct length.
Whitespace is removed from the reference.
Declaration
public static string CreateQRReference(string rawReference)
Parameters
Type | Name | Description |
---|---|---|
System.String | rawReference | The raw string (digits and whitespace only). |
Returns
Type | Description |
---|---|
System.String | The QR reference. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The reference contains non-numeric characters or is too long |
FormatIban(String)
Formats an IBAN or creditor reference by inserting spaces
Spaces are inserted to form groups of 4 letters/digits. If a group of less than 4 letters/digits is needed, it appears at the end.
Declaration
public static string FormatIban(string iban)
Parameters
Type | Name | Description |
---|---|---|
System.String | iban | The IBAN or creditor reference without spaces. |
Returns
Type | Description |
---|---|
System.String | The formatted IBAN or creditor reference. |
FormatQrReferenceNumber(String)
Formats a QR reference number by inserting spaces.
Spaces are inserted to create groups of 5 digits. If a group of less than 5 digits is needed, it appears at the start of the formatted reference number.
Declaration
public static string FormatQrReferenceNumber(string refNo)
Parameters
Type | Name | Description |
---|---|---|
System.String | refNo | The reference number without white space. |
Returns
Type | Description |
---|---|
System.String | the formatted reference number. |
IsQrIban(String)
Indicates if the string is a valid QR-IBAN.
QR-IBANs are IBANs with an institution ID in the range 30000 to 31999 and a country code for Switzerland or Liechtenstein. Thus, they must have the format "CH..30...", "CH..31...", "LI..30..." or "LI..31...".
Declaration
public static bool IsQrIban(string iban)
Parameters
Type | Name | Description |
---|---|---|
System.String | iban | account number to check |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsValidIban(String)
Validates if the string is a valid IBAN number
The string is checked for valid characters, valid length and for a valid check digit. White space is ignored.
Declaration
public static bool IsValidIban(string iban)
Parameters
Type | Name | Description |
---|---|---|
System.String | iban | The IBAN to validate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsValidIso11649Reference(String)
Validates if the string is a valid ISO 11649 reference number
The string is checked for valid characters, valid length and a valid check digit. White space is ignored.
Declaration
public static bool IsValidIso11649Reference(string reference)
Parameters
Type | Name | Description |
---|---|---|
System.String | reference | The ISO 11649 creditor reference to validate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsValidQrReference(String)
Validates if the string is a valid QR reference.
A valid QR reference is a valid ISR reference.
The string is checked for valid characters, valid length and a valid check digit. White space is ignored.
Declaration
public static bool IsValidQrReference(string reference)
Parameters
Type | Name | Description |
---|---|---|
System.String | reference | The QR reference number to validate. |
Returns
Type | Description |
---|---|
System.Boolean |
|