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 SourceCleanedAndTrimmedText(String, SpsCharacterSet)
Returns a cleaned and trimmed text valid according to the specified character set.
Unsupported characters are replaced with supported characters, either with the same character without accent (e.g. A instead of Ă), with characters of similar meaning (e.g. TM instead of ™, ij instead of ij), with a space (for unsupported whitespace characters) or with a dot.
Leading and trailing whitespace is removed. Multiple consecutive spaces are replaced with a single whitespace.
Some valid letters can be represented either with a single Unicode code point or with two code points, e.g. the letter A with umlaut can be represented either with the single code point U+00C4 (latin capital letter A with diaeresis) or with the two code points U+0041 U+0308 (latin capital letter A, combining diaeresis). This will be detected and converted to the valid single code point form.
If text
is null
or the resulting string would be empty, null
is returned.
Declaration
public static string CleanedAndTrimmedText(string text, SpsCharacterSet characterSet)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | |
SpsCharacterSet | characterSet |
Returns
Type | Description |
---|---|
System.String |
CleanedText(String, SpsCharacterSet)
Returns a cleaned text valid according to the specified character set.
Unsupported characters are replaced with supported characters, either with the same character without accent (e.g. A instead of Ă), with characters of similar meaning (e.g. TM instead of ™, ij instead of ij), with a space (for unsupported whitespace characters) or with a dot.
Some valid letters can be represented either with a single Unicode code point or with two code points, e.g. the letter A with umlaut can be represented either with the single code point U+00C4 (latin capital letter A with diaeresis) or with the two code points U+0041 U+0308 (latin capital letter A, combining diaeresis). This will be detected and converted to the valid single code point form.
If text
is null
or the resulting string would be empty, null
is returned.
Declaration
public static string CleanedText(string text, SpsCharacterSet characterSet)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | |
SpsCharacterSet | characterSet |
Returns
Type | Description |
---|---|
System.String |
CleanValue(String, out Payments.CleaningResult)
Cleans a string value to make it viable for the Swiss Payment Standards 2018.
Unsupported characters are replaced with supported characters, either with the same character without accent (e.g. A instead of Ă), with characters of similar meaning (e.g. TM instead of ™, ij instead of ij), with a space (for unsupported whitespace characters) or with a dot.
Some valid letters can be represented either with a single Unicode code point or with two code points, e.g. the letter A with umlaut can be represented either with the single code point U+00C4 (latin capital letter A with diaeresis) or with the two code points U+0041 U+0308 (latin capital letter A, combining diaeresis). This will be detected and converted to the valid single code point form.
If value
is null
or the resulting string would be empty, 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 |
|
IsValidText(String, SpsCharacterSet)
Indicates if the text consists only of characters allowed in the specified character set.
This method does not attempt to deal with accents and umlauts built from two code points. It will
return false
if the text contains such characters.
Declaration
public static bool IsValidText(string text, SpsCharacterSet characterSet)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | text to check, possibly |
SpsCharacterSet | characterSet | Character set specifying valid characters. |
Returns
Type | Description |
---|---|
System.Boolean |
|