Skip to content

Commit

Permalink
Minor enhancements for version 2.3 of specification
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelbl committed May 31, 2024
1 parent 4bd9cc7 commit d70b10c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,25 @@
* If fields of both types are set, the address type becomes <i>conflicting</i>.
* Name and country code must always be set unless all fields are empty.
* </p>
* <p>
* Banks will no longer accept payments using the combined address elements starting November 21, 2025.
* Therefore, it is recommended to use structured addresses immediately.
* </p>
*/
public class Address implements Serializable {

/**
* Address type
* Address type.
* <p>
* Staring November 21, 2025, banks will only accepts payments with structured addresses.
* </p>
*/
public enum Type {
/**
* Undetermined
* <p>
* This is a temporary state and not suitable for a valid payment.
* </p>
*/
UNDETERMINED,
/**
Expand All @@ -39,6 +49,9 @@ public enum Type {
COMBINED_ELEMENTS,
/**
* Conflicting
* <p>
* This a an invalid state and will prevent the generation of a QR bill.
* </p>
*/
CONFLICTING
}
Expand Down Expand Up @@ -127,7 +140,8 @@ public void setName(String name) {
* Address line 1 contains street name, house number or P.O. box.
* </p>
* <p>
* This field is only used for combined elements addresses and is optional.
* This field is only used for combined address elements and is optional.
* Starting November 25, 2025, banks will no longer accept payments using combined address elements.
* </p>
*
* @return address line 1
Expand All @@ -146,7 +160,8 @@ public String getAddressLine1() {
* {@link Type#STRUCTURED}, in which case it becomes {@link Type#CONFLICTING}.
* </p>
* <p>
* This field is only used for combined elements addresses and is optional.
* This field is only used for combined address elements and is optional.
* Starting November 25, 2025, banks will no longer accept payments using combined address elements.
* </p>
*
* @param addressLine1 address line 1
Expand All @@ -162,7 +177,8 @@ public void setAddressLine1(String addressLine1) {
* Address line 2 contains postal code and town.
* </p>
* <p>
* This field is only used for combined elements addresses. For this type, it's mandatory.
* This field is only used for combined address elements. For this type, it's mandatory.
* Starting November 25, 2025, banks will no longer accept payments using combined address elements.
* </p>
*
* @return address line 2
Expand All @@ -181,7 +197,8 @@ public String getAddressLine2() {
* {@link Type#STRUCTURED}, in which case it becomes {@link Type#CONFLICTING}.
* </p>
* <p>
* This field is only used for combined elements addresses. For this type, it's mandatory.
* This field is only used for combined address elements. For this type, it's mandatory.
* Starting November 25, 2025, banks will no longer accept payments using combined address elements.
* </p>
*
* @param addressLine2 address line 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ public static boolean isValidQRReference(String reference) {
if (len != 27)
return false;

if ("000000000000000000000000000".equals(reference))
return false;

return calculateMod10(reference) == 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ void createQRReferenceWithWhitespace() {
Payments.createQRReference(" 12 3456 "));
}

@Test
void allZeroes_isInvalid() {
assertFalse(Payments.isValidQRReference("000000000000000000000000000"));
assertFalse(Payments.isValidQRReference("00 00000 00000 00000 00000 00000"));
}

@Test
void rawReferenceWithInvalidCharacters() {
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> Payments.createQRReference("1134a56"));
Expand Down

0 comments on commit d70b10c

Please sign in to comment.