PHP code example of peterbodnar.com / bsqr

1. Go to this page and download the library: Download peterbodnar.com/bsqr library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

peterbodnar.com / bsqr example snippets


use com\peterbodnar\bsqr;

$document = (new bsqr\model\Payment())
	->setDueDate("0000-00-00") // YYYY-MM-DD
	->setAmount(123.45, "EUR") // amount, currency code
	->setSymbols("1234567890", "308") // variable, constant symbol
	->addBankAccount("SK3112000000198742637541", "XXXXXXXXXXX") // iban, bic/swift
	->createPayDocument();

use com\peterbodnar\bsqr;

$document = (new bsqr\model\Pay())
	->setInvoiceId("1234567890")
	->addPayment(
 		(new bsqr\model\Payment())
		->setDueDate("0000-00-00")
		->setAmount(123.45, "EUR")
		->setSymbols("1234567890", "308")
		->addBankAccount("SK3112000000198742637541", "XXXXXXXXXXX")
		->addBankAccount("SK3112000000198742637542", "XXXXXXXXXXX")
		->addBankAccount("SK3112000000198742637543", "XXXXXXXXXXX")
		// ->setNote("Payment note")
		// ->setOriginatorsReferenceInformation("Originators Reference Information")
		// ->setDirectDebitExt( /* Direct Debit Extension */ )
		// ->setStandingOrderExt( /* Standing Order Extension */ )
	)
	->addPayment( /* 2nd payment */ )
	->addPayment( /* 3rd payment */ );

use com\peterbodnar\bsqr;

$bysquare = new bsqr\BySquare();

$svg = (string) $bysquare->render($document);

use com\peterbodnar\bsqr;

$bsqrCoder = new bsqr\utils\BsqrCoder();

$bsqrData = $bsqrCoder->encode($document);

use com\peterbodnar\bsqr;

$bsqrCoder = new bsqr\utils\BsqrCoder();

$document = $bsqrCoder->parse($bsqrData);