PHP code example of hevertonfreitas / phpix
1. Go to this page and download the library: Download hevertonfreitas/phpix 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/ */
hevertonfreitas / phpix example snippets
use Hevertonfreitas\PHPix\Payload;
use Hevertonfreitas\PHPix\QRCode;
// Instancia classe Payload com os dados do PIX a ser gerado
$payload = new Payload();
$payload
->setPixKey('PIXKEY1234567890', Payload::PIX_KEY_RANDOM)
->setTxid('1234567890')
->setAmount(200)
->setMerchantName('Nome')
->setMerchantCity('Cidade')
->setPostalCode('12345678');
// Retorna string do código do PIX gerado
$PixCopiaCola = $payload->getPayload();
// Instancia classe QRCode
$qrCode = new QRCode($payload);
// Retorna imagem em formato binário
$qrCodeImage = $qrCode->getPngImage();