kaio-souza/pix-php

A simple PIX generator


License
MIT

Documentation

PIX GENERATOR

A simple library to generate media / data to Copy and Paste Pix

Requeriments

  • To generate Images, the ext php-gd needs to be enable

Instatiate Class

Using Constants to Params (more secure, in cases of update)

$pix = new PixGenerator([
    MandatoryConfig::PIX_KEY => 'teste@teste.com',
    MandatoryConfig::MERCHANT_NAME => 'Tester',
]);

Using String

$pix = new PixGenerator([
   'pix_key' => 'teste@teste.com',
   'merchant_name' => 'Tester',
]);

More Params

$pix = new PixGenerator([
    MandatoryConfig::PIX_KEY => 'teste@teste.com',
    MandatoryConfig::MERCHANT_NAME => 'Tester',
    OptionalConfig::MERCHANT_CITY => 'SAO PAULO', // 'SAO PAULO' is the DefaultValue
    OptionalConfig::CURRENCY => '986', // 986 = BRL | is the DefaultValue
    OptionalConfig::COUNTRY_CODE => 'BR', // 'BR' is the default Alpha2 value
]);

Get QRCode Text

echo $pix->getQrCodeText(20, 'Teste Lala');
// returns 00020126510014br.gov.bcb.pix0115teste@teste.com0210Teste Lala520400005303986540520,005802BR5906Tester6002BR62270523bca37b925af47abd511393463041FC2

Get QRCode Image

// returns QRCode PNG output
$code = $pix->getQrCode(20, 'Teste Lala');
// Save the output on file
file_put_contents('qr.png', $code);

or

$code = $pix->getBase64QrCode('14,50', 'Teste Lala');

// show QRCODE on HTML img tag
echo "<img src='data:image/png;base64, {$code}' />";

** The amount accepts a comma or dots to separate the decimal places