This example shows how to create the raw Swiss Payments Code. It is the textual representation of all data encoded in the QR code.

import ch.codeblock.qrinvoice.QrInvoiceCodeCreator;
import ch.codeblock.qrinvoice.model.QrInvoice;
import ch.codeblock.qrinvoice.model.builder.QrInvoiceBuilder;

// ...

final QrInvoice qrInvoice = // create using QrInvoiceBuilder;

// the resulting String is the Swiss Payments Code which is the one encoded in the QR-Code
final String swissPaymentsCode = QrInvoiceCodeCreator.create()
    .qrInvoice(qrInvoice)
    .createSwissPaymentsCode();
System.out.println(swissPaymentsCode);

Prints a SPC like the following

SPC
0200
1
CH4431999123000889012
S
Robert Schneider AG
Rue du Lac
1268
2501
Biel
CH







1949.75
CHF
S
Pia-Maria Rutschmann-Schnyder
Grosse Marktgasse
28
9400
Rorschach
CH
QRR
210000000003139471430009017
Instruction of 03.04.2019
EPD
//S1/10/10201409/11/190512/20/1400.000-53/30/106017086/31/180508/32/7.7/40/2:10;0:30
Name AV1: UV;UltraPay005;12345
Name AV2: XY;XYService;54321