RikudouSage / QrPaymentCZ

Simple library to generate QR payment for Czech Republic
MIT License
26 stars 7 forks source link

Implementation for Slovakia #3

Closed zemnet closed 6 years ago

zemnet commented 7 years ago

Hi, what must we do to allow works with Slovak banks?

Thank you

RikudouSage commented 7 years ago

For Slovak banks it's pretty much the same, but if I recall correctly they don't use BBAN format anymore, so you must initiate the class by IBAN and change currency and country:

<?php
use rikudou\CzQrPayment\QrPayment;

$payment = QrPayment::fromIBAN("SK0809000000000123123123")
  ->setCountry("SK")
  ->setCurrency("EUR");

$payment->setAmount(100); // set amount to 100 EUR

echo $payment->getQrString(); // returns the string to be encoded in QR code

// if you use endroid/qrcode 1.6:

$payment->getQrImage(true) // renders the image and sets content-type
  ->setSize(300)          // to image/png
  ->render();

So pretty much the only thing that changes is how you initiate the class.

RikudouSage commented 7 years ago

You can also use the old format that banks don't support anymore:

<?php

use rikudou\CzQrPayment\QrPayment;

$payment = (new QrPayment("0123123123", "0900"))
  ->setCountry("SK")
  ->setCurrency("EUR");

This code provides the same result as in previous comment.

RikudouSage commented 7 years ago

Another way is to extend the class, something like this:

<?php

use rikudou\CzQrPayment\QrPayment;

class SKPayment extends QrPayment {

  public function __construct($iban, $options = null) {
    parent::__construct(0, 0, $options);
    $this->iban = $iban;
    $this->setCountry("SK");
    $this->setCurrency("EUR");
  }

}
zemnet commented 7 years ago

Yes, I test it on my webapp with this config, but mobile app for Tatrabanka and VUB return error "wrong format" ...

          $payment = QrPayment::fromIBAN("SK........")->setOptions([
              QrPaymentOptions::AMOUNT => 100,
              QrPaymentOptions::VARIABLE_SYMBOL => 1502,
              QrPaymentOptions::CONSTANT_SYMBOL => '0308',
              QrPaymentOptions::CURRENCY => "EUR",
              QrPaymentOptions::COUNTRY => "SK",
              QrPaymentOptions::DUE_DATE => date("Y-m-d", strtotime("+14 days"))
            ]);

          $payment->getQrImage(true)
            ->render();
RikudouSage commented 6 years ago

Slovak banks use entirely different format called "PAY by square". Since I don't have a Slovak account, I cannot implement PAY by square.

RikudouSage commented 6 years ago

@zemnet Well, here you go.

zemnet commented 6 years ago

@RikudouSage Hey man, you are hero :) I test it at tomorrow. Thank you