PHP code example of rikudou / czqrpayment

1. Go to this page and download the library: Download rikudou/czqrpayment 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/ */

    

rikudou / czqrpayment example snippets




use Rikudou\CzQrPayment\QrPayment;
use Rikudou\Iban\Iban\IBAN;
use Rikudou\Iban\Iban\CzechIbanAdapter;

// initialized with IBAN directly
$payment = new QrPayment(new IBAN('CZ5530300000001325090010'));

// initialized from Czech account number and bank code
$payment = new QrPayment(new CzechIbanAdapter('1325090010', '3030'));

// the IBAN classes don't use strict typing so you can also use implicit conversion like this
// beware of bank codes that start with zero, those need to always be supplied as a string (like 0300)
$payment = new QrPayment(new CzechIbanAdapter(1325090010, 3030));




use Rikudou\CzQrPayment\QrPayment;

$payment = QrPayment::fromAccountAndBankCode('1325090010', '3030');

// the class does not use strict typing so you can also use implicit conversion like this
// beware of bank codes that start with zero, those need to always be supplied as a string (like 0300)
$payment = QrPayment::fromAccountAndBankCode(1325090010, 3030);



use Rikudou\CzQrPayment\QrPayment;
use Rikudou\CzQrPayment\Options\QrPaymentOptions;
use Rikudou\Iban\Iban\CzechIbanAdapter;

$payment = new QrPayment(new CzechIbanAdapter('1325090010', '3030'), [
  QrPaymentOptions::VARIABLE_SYMBOL => 123456,
  QrPaymentOptions::AMOUNT => 100,
  QrPaymentOptions::CURRENCY => "CZK",
  QrPaymentOptions::DUE_DATE => date("Y-m-d", strtotime("+14 days"))
]);

// or you can assign the options later via setOptions()

$payment->setOptions([
  QrPaymentOptions::VARIABLE_SYMBOL => 123456,
  QrPaymentOptions::AMOUNT => 100,
  QrPaymentOptions::CURRENCY => "CZK",
  QrPaymentOptions::DUE_DATE => date("Y-m-d", strtotime("+14 days")),
  QrPaymentOptions::INSTANT_PAYMENT => true,
]);



use Rikudou\CzQrPayment\QrPayment;
use Rikudou\Iban\Iban\CzechIbanAdapter;

$payment = new QrPayment(new CzechIbanAdapter('1325090010', '3030'));
$payment
    ->setVariableSymbol(123456)
    ->setAmount(100)
    ->setCurrency("CZK")
    ->setDueDate(new DateTimeImmutable('+14 days'))
    ->setInstantPayment(true);



use Rikudou\CzQrPayment\QrPayment;
use Endroid\QrCode\QrCode;

$payment = new QrPayment(...);

$qrCode = $payment->getQrCode();

// get the raw image data and display them in the browser
header('Content-Type: image/png');
echo $qrCode->getRawString();

// use in an img html tag
echo "<img src='{$qrCode->getDataUri()}'>";

// write to a file
$qrCode->writeToFile('/tmp/some-file.png');

// get the raw object from the underlying system
$raw = $qrCode->getRawObject();
// let's assume we're using endroid/qr-code v4
assert($raw instanceof QrCode);
// do some custom transformations
$raw->setLabelFontSize(15);
// the object is still referenced by the adapter, meaning we can now render it the same way as before
echo "<img src='{$qrCode->getDataUri()}'>";


use Rikudou\CzQrPayment\QrPayment;
use Rikudou\CzQrPayment\Options\QrPaymentOptions;
use Rikudou\Iban\Iban\CzechIbanAdapter;

$payment = new QrPayment(new CzechIbanAdapter('1325090010', '3030'));

// or with options

$payment = new QrPayment(new CzechIbanAdapter('1325090010', '3030'), [
  QrPaymentOptions::AMOUNT => 100
]);


use Rikudou\CzQrPayment\QrPayment;
use Rikudou\CzQrPayment\Options\QrPaymentOptions;
use Rikudou\Iban\Iban\CzechIbanAdapter;

$payment = new QrPayment(new CzechIbanAdapter('1325090010', '3030'));

$payment->setOptions([
  QrPaymentOptions::AMOUNT => 100
]);



use Rikudou\CzQrPayment\QrPayment;
use Rikudou\Iban\Iban\CzechIbanAdapter;

$payment = new QrPayment(new CzechIbanAdapter('1325090010', '3030'));
$myIBAN = $payment->getIban(); 


use Rikudou\CzQrPayment\QrPayment;
use Rikudou\CzQrPayment\Options\QrPaymentOptions;
use Rikudou\Iban\Iban\CzechIbanAdapter;

$payment = new QrPayment(new CzechIbanAdapter('1325090010', '3030'), [
  QrPaymentOptions::AMOUNT => 100,
  QrPaymentOptions::VARIABLE_SYMBOL => 1502,
  QrPaymentOptions::DUE_DATE => new DateTimeImmutable('+14 days'),
]);

$qrString = $payment->getQrString(); // SPD*1.0*ACC:CZ5530300000001325090010*AM:100.00*CC:CZK*X-PER:7*X-VS:1502*DT:20210413


use Rikudou\CzQrPayment\QrPayment;

$payment = QrPayment::fromAccountAndBankCode('1325090010', '3030');
// do all the other stuff



use Rikudou\CzQrPayment\QrPayment;
use Rikudou\CzQrPayment\Options\QrPaymentOptions;

$payment = QrPayment::fromAccountAndBankCode('1325090010', '3030')->setOptions([
  QrPaymentOptions::AMOUNT => 100
]);

header('Content-Type: image/png');
echo $payment->getQrImage()->writeString();