diff --git a/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeConfig.kt b/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeConfig.kt index 8ed27e2..c0347c7 100644 --- a/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeConfig.kt +++ b/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeConfig.kt @@ -13,7 +13,14 @@ open class EpcQrCodeConfig( open val reference: String? = null, - open val noteToUser: String? = null, + /** + * Beneficiary to originator information. + * + * The text contained in Display must be shown to the user after decoding and serves a + * short textual description of what the user is going to initiate. + * This text must not be forwarded with the data handed over to the payment system. + */ + open val informationForUser: String? = null, open val purposeCode: String? = null, diff --git a/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeGenerator.kt b/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeGenerator.kt index a38869d..a98d45d 100644 --- a/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeGenerator.kt +++ b/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeGenerator.kt @@ -48,7 +48,7 @@ open class EpcQrCodeGenerator { param.purposeCode, null, param.reference, - param.noteToUser + param.informationForUser ) open fun generateAsString(param: EpcQrCodeConfig): String { @@ -66,22 +66,22 @@ open class EpcQrCodeGenerator { epcQrCodeBuilder.appendLine(mapNullable(epcQrCode.amount?.let { (epcQrCode.currencyCode ?: EpcQrCodeValues.CurrencyCodeDefaultValue) + it })) // TODO: ensure that amount is converted to the correct format epcQrCodeBuilder.appendLine(mapNullable(epcQrCode.purposeCode)) - if (epcQrCode.remittanceText != null || epcQrCode.originatorInformation != null) { + if (epcQrCode.remittanceText != null || epcQrCode.informationForUser != null) { epcQrCodeBuilder.appendLine(mapNullable(epcQrCode.remittanceReference)) } else { epcQrCodeBuilder.append(mapNullable(epcQrCode.remittanceReference)) } - if (epcQrCode.remittanceText != null || epcQrCode.originatorInformation != null) { - if (epcQrCode.originatorInformation != null) { + if (epcQrCode.remittanceText != null || epcQrCode.informationForUser != null) { + if (epcQrCode.informationForUser != null) { epcQrCodeBuilder.appendLine(mapNullable(epcQrCode.remittanceText)) } else { epcQrCodeBuilder.append(mapNullable(epcQrCode.remittanceText)) } } - if (epcQrCode.originatorInformation != null) { - epcQrCodeBuilder.append(epcQrCode.originatorInformation) + if (epcQrCode.informationForUser != null) { + epcQrCodeBuilder.append(epcQrCode.informationForUser) } return epcQrCodeBuilder.toString() diff --git a/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeValues.kt b/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeValues.kt index 76ff201..1c8b4e5 100644 --- a/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeValues.kt +++ b/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeValues.kt @@ -70,7 +70,14 @@ open class EpcQrCodeValues( open val remittanceText: String?, - open val originatorInformation: String? + /** + * Beneficiary to originator information. + * + * The text contained in Display must be shown to the user after decoding and serves a + * short textual description of what the user is going to initiate. + * This text must not be forwarded with the data handed over to the payment system. + */ + open val informationForUser: String? ) { diff --git a/EpcQrCode/src/commonTest/kotlin/net.codinux.banking.epcqrcode/EpcQrCodeGeneratorTest.kt b/EpcQrCode/src/commonTest/kotlin/net.codinux.banking.epcqrcode/EpcQrCodeGeneratorTest.kt index 80c47ac..4f4b569 100644 --- a/EpcQrCode/src/commonTest/kotlin/net.codinux.banking.epcqrcode/EpcQrCodeGeneratorTest.kt +++ b/EpcQrCode/src/commonTest/kotlin/net.codinux.banking.epcqrcode/EpcQrCodeGeneratorTest.kt @@ -34,7 +34,7 @@ class EpcQrCodeGeneratorTest { """.trimIndent()) - assertEquals(10, result.lines().size) // if no reference text or note to user is set, then QR code may only contain the minimum of 10 lines and no empty lines afterwards + assertEquals(10, result.lines().size) // if no reference text or information for user is set, then QR code may only contain the minimum of 10 lines and no empty lines afterwards } @Test @@ -58,13 +58,13 @@ class EpcQrCodeGeneratorTest { $referenceText """.trimIndent()) - assertEquals(11, result.lines().size) // no note to user -> no 12th line may be contained in generated QR code + assertEquals(11, result.lines().size) // no information for user -> no 12th line may be contained in generated QR code } @Test - fun includingNoteToUser() { - val noteToUser = "Mach uns reich, Baby" - val config = basicDataConfig(noteToUser = noteToUser) + fun includingInformationForUser() { + val informationForUser = "Mach uns reich, Baby" + val config = basicDataConfig(informationForUser = informationForUser) val result = underTest.generateAsString(config) @@ -80,10 +80,10 @@ class EpcQrCodeGeneratorTest { - $noteToUser + $informationForUser """.trimIndent()) - assertEquals(12, result.lines().size) // note to user set -> contains the maximum of 12 lines but no line separator at end of 12th line + assertEquals(12, result.lines().size) // information for user set -> contains the maximum of 12 lines but no line separator at end of 12th line } @@ -109,6 +109,6 @@ class EpcQrCodeGeneratorTest { assertEquals(1000018, result.bytes.size) } - private fun basicDataConfig(referenceText: String? = null, noteToUser: String? = null, imageFormat: ImageFormat = ImageFormat.PNG) = - EpcQrCodeConfig(ReceiverName, ReceiverIban, reference = referenceText, noteToUser = noteToUser, imageFormat = imageFormat) + private fun basicDataConfig(referenceText: String? = null, informationForUser: String? = null, imageFormat: ImageFormat = ImageFormat.PNG) = + EpcQrCodeConfig(ReceiverName, ReceiverIban, reference = referenceText, informationForUser = informationForUser, imageFormat = imageFormat) } \ No newline at end of file diff --git a/EpcQrCode/src/commonTest/kotlin/net.codinux.banking.epcqrcode/parser/EpcQrCodeParserTest.kt b/EpcQrCode/src/commonTest/kotlin/net.codinux.banking.epcqrcode/parser/EpcQrCodeParserTest.kt index 36ea780..81ec55f 100644 --- a/EpcQrCode/src/commonTest/kotlin/net.codinux.banking.epcqrcode/parser/EpcQrCodeParserTest.kt +++ b/EpcQrCode/src/commonTest/kotlin/net.codinux.banking.epcqrcode/parser/EpcQrCodeParserTest.kt @@ -192,7 +192,7 @@ Netter Text für den Zahlenden, damit dieser weiß, was er zahlt und auc assertEquals(purposeCode, epcQrCode.purposeCode) assertEquals(reference, epcQrCode.remittanceReference) assertEquals(text, epcQrCode.remittanceText) - assertEquals(displayText, epcQrCode.originatorInformation) + assertEquals(displayText, epcQrCode.informationForUser) } }