Added README

This commit is contained in:
dankito 2024-10-16 01:21:14 +02:00
parent 423887cf53
commit c6ac784e1f
3 changed files with 144 additions and 0 deletions

View File

@ -0,0 +1,32 @@
package net.codinux.banking.epcqrcode.examples
import net.codinux.banking.epcqrcode.EpcQrCodeConfig
import net.codinux.banking.epcqrcode.ImageFormat
class EpcQrCodeGeneratorExamples {
fun generateEpcQrCode() {
val generator = net.codinux.banking.epcqrcode.EpcQrCodeGenerator()
// these are the only two mandatory fields:
val receiverName = "Belgian Red Cross"
val iban = "BE72000000001616"
// optional but recommended fields:
val bic: String? = null
val amount: String? = "1"
val reference: String? = "Donation"
val informationForUser: String? = "Was für ein schönes EPC QR Code Beispiel" // not used / displayed by most applications
val qrCodeHeightAndWidth = 400
val imageFormat = ImageFormat.PNG
// generate EPC QR code and QR code image
val result = generator.generateEpcQrCode(EpcQrCodeConfig(receiverName, iban, bic, amount, reference, informationForUser,
qrCodeHeightAndWidth = qrCodeHeightAndWidth, imageFormat = imageFormat))
val imageBytes = result.bytes // now show these in UI
}
}

View File

@ -0,0 +1,20 @@
package net.codinux.banking.epcqrcode.examples
class EpcQrCodeParserExamples {
fun decode() {
val decodedQrCodeText: String = "..." // the text that is contained / read from QR code
val parser = net.codinux.banking.epcqrcode.parser.EpcQrCodeParser()
val result = parser.parseEpcQrCode(decodedQrCodeText)
val epcQrCode = result.epcQrCode
if (epcQrCode != null) {
println("Receiver = ${epcQrCode.receiverName}, IBAN = ${epcQrCode.iban}, amount = ${epcQrCode.amount}, ...")
} else {
println("Code not decode EPC QR code: ${result.error}")
}
}
}

92
README.md Normal file
View File

@ -0,0 +1,92 @@
# EPC QR Code
Vermarktet als GiroCode, scan2Code, Zahlen mit Code, ... ist der EPC QR Code ein Standard des European Payments Council
zum Übermitteln von Überweisungsdaten mittels eines QR Codes.
Der EPC QR Code enthält Überweisungsdaten wie IBAN, Empfängername, Betrag, ...
Eine Clientanwendung scannt dieses QR Code und kann sofort alle Überweisungsdaten anzeigen und, sofern vom Kunden gewünscht,
diese Überweisung direkt ausführen.
## Setup
### Gradle:
```
repositories {
// ... mavenCentral() etc.
maven {
setUrl("https://maven.dankito.net/api/packages/codinux/maven")
}
}
dependencies {
implementation("net.codinux.banking.epcqrcode:epc-qr-code:0.5.0")
}
```
### Maven:
```xml
<repositories>
<repository>
<id>codinux</id>
<url>https://git.dankito.net/api/packages/codinux/maven</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.codinux.banking.epcqrcode</groupId>
<artifactId>epc-qr-code-jvm</artifactId>
<version>0.5.0</version>
</dependency>
</dependencies>
```
## EPC QR Code erstellen
```kotlin
val generator = net.codinux.banking.epcqrcode.EpcQrCodeGenerator()
// these are the only two mandatory fields:
val receiverName = "Belgian Red Cross"
val iban = "BE72000000001616"
// optional but recommended fields:
val bic: String? = null
val amount: String? = "1"
val reference: String? = "Donation"
val informationForUser: String? = "Was für ein schönes EPC QR Code Beispiel" // not used / displayed by most applications
val qrCodeHeightAndWidth = 400
val imageFormat = ImageFormat.PNG
// generate EPC QR code and QR code image
val result = generator.generateEpcQrCode(EpcQrCodeConfig(receiverName, iban, bic, amount, reference, informationForUser,
qrCodeHeightAndWidth = qrCodeHeightAndWidth, imageFormat = imageFormat))
val imageBytes = result.bytes // now show these in UI
```
## EPC QR Code dekodieren
Dekodieren Sie zuerst den QR Code mittels einer QR Code Library. Den im QR Code Text übergeben Sie dann an
`EpcQrCodeParser` zum dekodieren der Überweisungsdaten:
```kotlin
val decodedQrCodeText: String = "..." // the text that is contained / read from QR code
val parser = net.codinux.banking.epcqrcode.parser.EpcQrCodeParser()
val result = parser.parseEpcQrCode(decodedQrCodeText)
val epcQrCode = result.epcQrCode
if (epcQrCode != null) {
println("Receiver = ${epcQrCode.receiverName}, IBAN = ${epcQrCode.iban}, amount = ${epcQrCode.amount}, ...")
} else {
println("Code not decode EPC QR code: ${result.error}")
}
```