PHP code example of fritak / eet

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

    

fritak / eet example snippets


use Fritak\eet\Sender;

$sender = new Sender(__DIR__ . '/config.json'); // load Sender with configuration

$sender->addReceipt(['uuid_zpravy' => 'b3a09b52-7c87-4014-a496-4c7a53cf9125', 'porad_cis' => 68, 'celk_trzba' => 546]);

// You can let uuid_zpravy empty, it will be  automatically generated
$sender->addReceipt(['porad_cis' => 69, 'celk_trzba' => 748]);

foreach($sender->sendAllReceipts() AS $response)
{
    $response->Potvrzeni->fik; // Your FIK - Fiscal Identification Code ("Fiskální identifikační kód")
}     

$sender->changeCertificate($certificate, $password);
$sender->changeDefaultValues($dic, $workshopId, $cashRegisterId);

use Fritak\eet\Sender;
use Fritak\eet\Receipt;

$sender = new Sender(__DIR__ . '/config.json'); // load Sender with configuration

$receipt = new Receipt();
$receipt->uuid_zpravy = 'b3a09b52-7c87-4014-a496-4c7a53cf9125'; // Or empty, it will be  automatically generated
$receipt->porad_cis   = '68';
$receipt->celk_trzba  = 546;

$receipt->dic_popl    = 'CZ1212121218';
$receipt->id_provoz   = '273';
$receipt->id_pokl     = '1';
$receipt->dat_trzby   = new \DateTime();

// Now we try dry run. Returns boolean TRUE/FALSE
if ($sender->dryRunSend($receipt))
{
    // Send receipt
    $fik = $sender->send($receipt)->Potvrzeni->fik;
}

$sender = $this->context->getService('senderEet');
$sender->addReceipt(['porad_cis' => 85, 'celk_trzba' => 9875]);

foreach($sender->sendAllReceipts() AS $response)
{
    $response->Potvrzeni->fik;
}