PHP code example of nticaric / fiskalizacija

1. Go to this page and download the library: Download nticaric/fiskalizacija 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/ */

    

nticaric / fiskalizacija example snippets





use Carbon\Carbon;
use Nticaric\Fiskalizacija\Fiskalizacija;
use Nticaric\Fiskalizacija\Generators\BrojRacunaType;
use Nticaric\Fiskalizacija\Generators\PorezOstaloType;
use Nticaric\Fiskalizacija\Generators\PorezType;
use Nticaric\Fiskalizacija\Generators\RacunType;
use Nticaric\Fiskalizacija\Generators\RacunZahtjev;
use Nticaric\Fiskalizacija\Generators\ZaglavljeType;

$billNumber = new BrojRacunaType(1, "ODV1", "1");

$listPdv   = [];
$listPdv[] = new PorezType(25.1, 400.1, 20.1, null);
$listPdv[] = new PorezType(10.1, 500.1, 15.444, null);

$listPnp   = [];
$listPnp[] = new PorezType(30.1, 100.1, 10.1, null);
$listPnp[] = new PorezType(20.1, 200.1, 20.1, null);

$listOtherTaxRate   = [];
$listOtherTaxRate[] = new PorezOstaloType("Naziv1", 40.1, 453.3, 12.1);
$listOtherTaxRate[] = new PorezOstaloType("Naziv2", 27.1, 445.1, 50.1);
$bill               = new RacunType();

$bill->setOib("32314900695");
$bill->setOznSlijed("P");
$bill->setUSustPdv(true);
$bill->setDatVrijeme("15.07.2014T20:00:00");

$bill->setBrRac($billNumber);
$bill->setPdv($listPdv);
$bill->setPnp($listPnp);
$bill->setOstaliPor($listOtherTaxRate);
$bill->setIznosOslobPdv(23.5);
$bill->setIznosMarza(32.0);
$bill->setIznosNePodlOpor(5.1);
$bill->setIznosUkupno(456.1);
$bill->setNacinPlac("G");
$bill->setOibOper("34562123431");

$fis = new Fiskalizacija(
    $_ENV['CERTIFICATE_PATH'],
    $_ENV['CERTIFICATE_PASSWORD'],
    "TLS",
    true
);

$zastKod = $bill->generirajZastKod(
    $fis->getPrivateKey(),
    $bill->getOib(),
    $bill->getDatVrijeme(),
    $billNumber->getBrOznRac(),
    $billNumber->getOznPosPr(),
    $billNumber->getOznNapUr(),
    $bill->getIznosUkupno()
);

$bill->setZastKod($zastKod);
$bill->setNakDost(false);

$billRequest = new RacunZahtjev();
$billRequest->setRacun($bill);

$zaglavlje = new ZaglavljeType;

$billRequest->setZaglavlje($zaglavlje);

$res = $fis->signAndSend($billRequest);
$jir = $res->getJir();
 
$qrGenerator = new QRGenerator($jir, "15.07.2014T20:00:00", 456.1);
echo $qrGenerator->generateUrl(); // Output the URL
//echo $qrGenerator->getQrCode(); // Output the base64-encoded QR code image



use Nticaric\Fiskalizacija\SoapClient;
use Nticaric\Fiskalizacija\XMLSerializer;
use Nticaric\Fiskalizacija\Generators\EchoRequest;

$message = "proizvoljan tekst";

$echoRequest = new EchoRequest($message);

$serializer = new XMLSerializer($echoRequest);
$xml        = $serializer->toXml();

$soapClient  = new SoapClient("https://cistest.apis-it.hr:8449/FiskalizacijaServiceTest");
$xmlEnvelope = $soapClient->addEnvelope($xml);

$res = $soapClient->send($xmlEnvelope);