rikudousage / qrpaymentsk Goto Github PK
View Code? Open in Web Editor NEWQR payment generator for Slovak banks (the bysquare standard)
License: MIT License
QR payment generator for Slovak banks (the bysquare standard)
License: MIT License
Hi,
the QrCode seems to be working perfectly.
I would like to ask, if there is a way to add also the PayBySquare logo as in the logo manual
https://www.sbaonline.sk/wp-content/uploads/2020/03/pay-by-square-logo-manual-1_0_4.pdf
Or just point me to some peace of code.
regards
hudecof
Hello,
I need to have a QR code generated in GIF format.
Is it possible to specify the image type with some parameter?
Or should I convert the PNG to GIF myself?
Thanks a lot for the answer
Best Regards
Michal
Prosím o windows support.
Malo by stačiť vytvoriť podmienku po neúspešnom exec('which xz', $output, $return); na windows variantu. exec('where xz', $output, $return);
<?php
use rikudou\SkQrPayment\QrPayment;
use Rikudou\Iban\Iban\IBAN;
$payment = new QrPayment(new IBAN('SK6807200002891987426353'));
$payment
->setAmount(500)
->setVariableSymbol('123456')
->setDueDate(new DateTime('+1 week'))
;
$qrString = $payment->getQrString();
// $qrString now holds the string to embed inside the QR code, in this example:
// 0004U0001M8GLP3E8KPT058IQ99QISMB02IH36MOD4BCKQQGVDE4641AOA2NURPCOPSALFG0LPG1C6N0E2JMC7RG2F4L2E57OCSHOUROGHOC8VTTPHHRFHU6VFTM8N80
$qrCode = $payment->getQrImage();
// send to browser
header('Content-Type: ' . $qrCode->getContentType());
echo $qrCode->writeString();
Testing on local testserver with PHP 8.1 in PC (Win10 x64): as soon as the code reaches $qrString = $payment->getQrString();
it quits with webpage page saying:
This page isn’t working
localhost is currently unable to handle this request.
HTTP ERROR 500
Installed with php composer.phar update --no-cache --with-all-dependencies
UPDATE
Tested a bit more: in the public function getQrString()
the problem starts with the line $xzBinary = $this->getXzBinary();
. As soon as it reaches this line, code breaks and all stops.
Now I do understood I need something called "xz binary" and set its path in the options for $payment
using ->setXzBinary('/path/to/xz')
. On Wikipedia I find those are "XZ Utils (previously LZMA Utils) is a set of free software command-line lossless data compressors, including the programs lzma and xz, for Unix-like operating systems and, from version 5.0 onwards, Microsoft Windows."
QUESTION IS: where to get those XZ binaries??? I found one here: https://tukaani.org/xz/xz-5.2.9-windows.7z
I did extract those to root "xz" folder, I set ->setXzBinary('/xz')
but it still does not work.
Ah, I see: correct path shout start without the /
, so that it is ->setXzBinary('xz')
- now it passed!
YOU CAN SET THIS ISSUE AS SOLVED NOW...
Jakoze sorry, ale jak sa da toto MANUALNE NAINSTALOVAT?!
Reku, urobim rychly test podla prikladu co tu uvadzas, a jeeeb:
use rikudou\SkQrPayment\QrPayment;
use Rikudou\Iban\Iban\IBAN;
$payment = new QrPayment(new IBAN('SK6807200002891987426353'));
$payment
->setAmount(500)
->setVariableSymbol('123456')
->setDueDate(new DateTime('+1 week'))
;
$qrString = $payment->getQrString();
// $qrString now holds the string to embed inside the QR code, in this example:
// 0004U0001M8GLP3E8KPT058IQ99QISMB02IH36MOD4BCKQQGVDE4641AOA2NURPCOPSALFG0LPG1C6N0E2JMC7RG2F4L2E57OCSHOUROGHOC8VTTPHHRFHU6VFTM8N80
$qrCode = $payment->getQrImage();
// send to browser
header('Content-Type: ' . $qrCode->getContentType());
echo $qrCode->writeString();
Fatal error: Class 'rikudou\SkQrPayment\QrPayment' not found in Z:_SERVER_\root\www...\index.php on line 108
Boha, preco nemozes spravit BEZNY NORMALNY SPOSOB IMPLEMENTACIE JAK VACSINA NORMNALNYCH KODEROV, al epouzijes PREIJEBANE use
??? Nejake include/require - nic, ee, vobec?! Neee, ty radsej vymyslis NEPOCHOPITELNY SPOSOB...cele zle, a take nadejne to s tebou bolo, skoda!
Toto jednoducho priemerne zdatny clovek nema sancu pochopit, lebo implementacia MANUALNA nie je nikde uvedena!!!! composer require rikudou/skqrpayment
si strc vies kam...nepouzitelne, nepouzivam ziadny prijebany redakcny system, kurwa!
setXzBinary() ....
There are symbols with leading zeros, e.g. 0308
https://www.mbank.sk/pomoc/info/ucty/zoznam-najpouzivanejsich-konstantnych-symbolov.html. If you treat it as an integer, the first zero will be ommited resulting in an incorrect symbol 308
.
In XzBinaryLocator.php there is on line 22:
exec('which xz', $output, $return);
This should be wrapped to check if php host is linux or windows:
if (stristr(PHP_OS, 'LINUX')) { exec( 'which xz', $output, $return ); } elseif (stristr(PHP_OS, 'WIN')) { exec( 'where xz', $output, $return ); } else { throw new QrPaymentException("not supported OS"); }
I'm using the code from the readme at https://github.com/RikudouSage/QrPaymentSK#getting-the-result and after running composer require rikudou/skqrpayment
and calling $payment->getQrImage();
this is what I'm getting:
rikudou\SkQrPayment\Exception\QrPaymentException: Error: library endroid/qr-code is not loaded. in rikudou\SkQrPayment\QrPayment->getQrImage() (line 247 of /app/vendor/rikudou/skqrpayment/src/QrPayment.php).
I tried adding them manually by running composer require endroid/qr-code
and composer require rikudou/qr-payment-qr-code-provider
but the same thing is happening.
I also tried modifying $payment->getQrImage();
to $payment->getQrCode();
but another error is happening:
Rikudou\QrPaymentQrCodeProvider\Exception\NoProviderFoundException: No QR code provider found. in Rikudou\QrPaymentQrCodeProvider\QrCodeProviderLocator->getProvider() (line 41 of /app/vendor/rikudou/qr-payment-qr-code-provider/src/QrCodeProviderLocator.php).
I'm trying to add this to a Drupal 9 site using PHP 7.4. What am I doing wrong?
When using LZMA for Windows, the Windows doesn't like this ${xzBinary} '--format=raw' '--lzma1=lc=3,lp=0,pb=2,dict=128KiB' '-c' '-'
. It treads ' as separate command:
php .\test.php
xz: '--format=raw': No such file or directory
xz: '--lzma1=lc=3,lp=0,pb=2,dict=128KiB': No such file or directory
xz: '-c': No such file or directory
xz: '-': No such file or directory
After removing ' , everything works just fine. Are they required for some other OS ?
<?php
require_once('vendor/autoload.php');
use rikudou\SkQrPayment\QrPayment;
use Rikudou\Iban\Iban\IBAN;
$payment = new QrPayment();
$payment
->setXzBinary('xz')
->setCurrency('EUR')
->setAmount(10)
->setComment('financny dar, ')
->setIbans([
new IBAN('SK6807200002891987426353')
]);
$qrString = $payment->getQrString();
echo $qrString;
?>
Output string is 0005C00
???
Likewise, if I use your example from this webpage:
<?php
require_once('vendor/autoload.php');
use rikudou\SkQrPayment\QrPayment;
use Rikudou\Iban\Iban\IBAN;
$payment = new QrPayment(new IBAN('SK6807200002891987426353'));
$payment
->setXzBinary('xz')
->setAmount(500)
->setVariableSymbol('123456')
->setDueDate(new DateTime('+1 week'))
;
$qrString = $payment->getQrString();
// $qrString now holds the string to embed inside the QR code, in this example:
// 0004U0001M8GLP3E8KPT058IQ99QISMB02IH36MOD4BCKQQGVDE4641AOA2NURPCOPSALFG0LPG1C6N0E2JMC7RG2F4L2E57OCSHOUROGHOC8VTTPHHRFHU6VFTM8N80
echo $qrString;
?>
Output string is 0004U00
instead of supposed 0004U0001M8GLP3E8KPT058IQ99QISMB02IH36MOD4BCKQQGVDE4641AOA2NURPCOPSALFG0LPG1C6N0E2JMC7RG2F4L2E57OCSHOUROGHOC8VTTPHHRFHU6VFTM8N80
Did I miss to enable something somewhere, like some PHP extension or what?
Using QrPaymentSK v4.2.1
UPDATE
I was investigating some more in your getQrString()
function in QrPayment.php file, and I found out that until the line 196 proc_close($xzProcess);
variable $hashedData
still holds all the correct values that were defined in $payment
options (Ô ŔŹ 1 1 10 EUR 20240611 financny dar, 1 SK7783605207004206972399 BREXSKBX 0 0
).
BUT as soon as the line $hashedData = bin2hex("\x00\x00" . pack('v', strlen($hashedData)) . $pipeOutput);
happens, the new variable $hashedData
suddenly becomes 00005600
.
Investigating even more: important variable $pipeOutput
is (seems to be) EMPTY, which means that stream_get_contents($xzProcessPipes[1])
returns nothing?!
Now as I search for the src of the $pipeOutput
I see it is probably made by $xzProcess
(cos that is the 1st time in the code it appears, thus my impression) which trying to call proc_open
and I see it is the only call to proc_open
in the file (so what I write further would have its logic, I guess), but interestingly enough, when I was trying to make Composer work I had to run it on a different PC, where I had to manually install PHP 8.1 from scratch, cos here on my PC where I run my testserver with PHP 8.1 it was Unable to launch a new process
, which I was told by one guy (I guess author of the Composer, I'm not sure now) might be caused because my server - for some reason - does not allow proc_open
. Which by itself is strange cos it is not disabled in the php.ini at all!
These are just my thoughts - still waiting for your actual answer tho!
UPDATE 2
Well, I tried it on that another PC where I was able successfully running Composer (= no problem with launching new process there), but the result is the same, thus I now think it is not the case of my server possibly not allowing proc_open
- IT HAS TO BE SOMETHING ELSE!!! Indeed, I tested on my actual local testserver if proc_open
works with this code, and it does work (output is echoed into the webpage in a loop):
<?php
set_time_limit(1800);
ob_implicit_flush(true);
$exe_command = 'C:\\Windows\\System32\\ping.exe -t google.com';
$descriptorspec = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout -> we use this
2 => array("pipe", "w") // stderr
);
$process = proc_open($exe_command, $descriptorspec, $pipes);
if (is_resource($process))
{
while( ! feof($pipes[1]))
{
$return_message = fgets($pipes[1], 1024);
if (strlen($return_message) == 0) break;
echo $return_message.'<br />';
ob_flush();
flush();
}
}
?>
If I save to a text file values with file_put_contents("test.txt", $pipeOutput.'<br>'.$hashedData.'<br>'.$xzProcessPipes[0].'<br>'.$xzProcessPipes[1]);
right after the line 200 $hashedData = bin2hex("\x00\x00" . pack('v', strlen($hashedData)) . $pipeOutput);
, then the result is: <br>00005600<br>Resource id #25<br>Resource id #26
(in case this info would help you somehow in your investigation at all).
Hmm, maybe the xz binary ($xzProcess
) is not producing expected result = no result at all, actually (maybe if you know some 100% functional xz binaries download link that you are using yourself, I could try those instead of those I have now)?
I just deleted everything in the xy folder and...no error was produced, and code works still - how come??? There are literally no files in the xz folder now, yet all seems to working OK (except the broken output string, of course) - WHAT IS GOING ON HERE???
I WOULD SAY THIS REVELATION ALONE BASICALLY SAYING WHERE THE RPOBLEM IS: does your script actually check not only for the xz binaries folder, but also for the actual binary files in there it requires for the actual code/output? Seems not...
Everything here is just my uncompetent thoughts...7+ hrs passed and I still wait for any reaction from you. :-(((
Proč je rozšíření třídy deprecated? Já si tak např. musel přetížit metodu getXzBinary()
, aby nekontrolovala existenci souboru xzPath
, neboť na hostingu sice je v /usr/bin/xc
ale přes file_exists
to neprošlo.
Properties variableSymbol
, specificSymbol
, constantSymbol
, dueDate
and xzPath
have default value null
.
Their getters allow to return null
(for symbol properties) or use fallback value.
Their setters don't allow set these properties back to null
.
Please allow set mentioned properties back to null
by allowing nullable type in parameters of setters.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.