false, 'message' => 'Invalid input']); exit; } if (!isset($baseDir)) $baseDir = $_SERVER['DOCUMENT_ROOT']; require $baseDir . '/../composer/vendor/autoload.php'; use Sprain\SwissQrBill as QrBill; // This is an example how to create a typical qr bill: // - with reference number // - with known debtor // - with specified amount // - with human-readable additional information // - using your QR-IBAN // // Likely the most common use-case in the business world. // Create a new instance of QrBill, containing default headers with fixed values $qrBill = QrBill\QrBill::create(); $name = trim((string)($rechnungenVorname ?? '') . ' ' . (string)($rechnungenName ?? '')); $strasse = (string)($rechnungenStrasse ?? ''); $hausnr = (string)($rechnungenHausnummer ?? ''); $plz = (string)($rechnungenPostleitzahl ?? ''); $ort = (string)($rechnungenOrt ?? ''); $qrBill->setCreditor( QrBill\DataGroup\Element\StructuredAddress::createWithStreet( $name, $strasse, $hausnr, $plz, $ort, 'CH' ) ); $iban = strtoupper(str_replace(' ', '', (string)($rechnungenIBAN ?? ''))); $qrBill->setCreditorInformation( QrBill\DataGroup\Element\CreditorInformation::create($iban) ); // Add debtor information // Who has to pay the invoice? This part is optional. $qrBill->setUltimateDebtor( QrBill\DataGroup\Element\StructuredAddress::createWithStreet( $_POST['vorname'] . ' ' . $_POST['name'], $_POST['strasse'], $_POST['hausnummer'], $_POST['plz'], $_POST['ort'], 'CH' ) ); // Add payment amount information // What amount is to be paid? $qrBill->setPaymentAmountInformation( QrBill\DataGroup\Element\PaymentAmountInformation::create( 'CHF', $totalPreis ) ); // Add payment reference // This is what you will need to identify incoming payments. $qrBill->setPaymentReference( QrBill\DataGroup\Element\PaymentReference::create( QrBill\DataGroup\Element\PaymentReference::TYPE_SCOR, QrBill\Reference\RfCreditorReferenceGenerator::generate($dbresult['order_id']) ) ); $month = date('m'); if ($month < 6){ $jahr = date('Y'); } else { $jahr = date('Y') + 1; } $referenz = "Startgebühren ". $wkName. " ".$jahr; // Optionally, add some human-readable information about what the bill is for. $qrBill->setAdditionalInformation( QrBill\DataGroup\Element\AdditionalInformation::create( $referenz ) ); // Now get the QR code image and save it as a file. /*try { $qrBill->getQrCode()->writeFile(__DIR__ . '/qrneu.png'); $qrBill->getQrCode()->writeFile(__DIR__ . '/qrneu.svg'); } catch (\Throwable $e) { foreach ($qrBill->getViolations() as $violation) { print $violation->getMessage()."\n"; } // Also print exception message when available error_log('QR bill error: ' . $e->getMessage()); exit; }*/ // Next: Output full payment parts, depending on the format you want to use: // // - FpdfOutput/fpdf-example.php // - HtmlOutput/html-example.php // - TcPdfOutput/tcpdf-example.php