manuelbl/SwissQRBill

ReferenceCode validation problem

Closed this issue · 4 comments

Kusig commented

It is actually not possible to use the normal ISO ReferenceCode.

When adding the Reference code to the bill, it is enlarged to 26 chars and the modulo10 is added.

bill.createAndSetQRReference(reference);

However, later on when generating the bill, the length is checked to be less than 26 chars in Payments.class:

public static boolean isValidISO11649Reference(String reference) {
reference = Strings.whiteSpaceRemoved(reference);
if (reference.length() >= 5 && reference.length() <= 25) {

The method createAndSetQRReference() indeed calculates and adds the checksum.

If you already have a valid ISO reference incl. checksum, you can simply add it using bill.setReference("...");

Kusig commented

Thanks for the feedback. However, I still don't get it really. The QR Reference is supposed to be 26+1 char length.

Therefore the check should be reference.length()<=26 and not 25.

Or do I missunderstand something here?

The QR reference and the ISO 11649 reference are two different types of references with two different sets of rules:

  • The QR reference is all numeric, 27 digits long with the last digit being the check digits.

  • The ISO 11649 reference is alphanumeric, of variable length (up to 25 characters) and with two digits at the third and fourth position serving as the check digits.

Kusig commented

Sorry, now I got it. My IBAN was wrong in my testcase. Now it is working all properly.
Thanks very much for this very helpful library!