try {
$api = Gerencianet::getInstance($options);
$pix = $api->pixCreateImmediateCharge([], $body);
if ($pix['txid']) {
$params = [
'id' => $pix['loc']['id']
];
// Gera QRCode
$qrcode = $api->pixGenerateQRCode($params);
echo 'Detalhes da cobrança:';
echo '
' . json_encode($pix, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . '
';
echo 'QR Code:';
echo '
' . json_encode($qrcode, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . '
';
echo 'Imagem:
';
echo '
';
} else {
echo '
' . json_encode($pix, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . '
';
}
} catch (GerencianetException $e) {
print_r($e->code);
print_r($e->error);
print_r($e->errorDescription);
} catch (Exception $e) {
print_r($e->getMessage());
}