PHP code example of krasnyd / eet-client-php

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

    

krasnyd / eet-client-php example snippets


use Krasnyd\Eet\Certificate;
use Krasnyd\Eet\ClientOptions;
use Krasnyd\Eet\EetClient;
use Krasnyd\Eet\Schema\EetSchema;
use Krasnyd\Eet\Schema\Trzba;
use Krasnyd\Eet\Schema\TrzbaData;
use Krasnyd\Eet\Schema\TrzbaHlavicka;

$trzba = new Trzba(
    hlavicka: new TrzbaHlavicka(
        uuidZpravy: '...', // UUID v4
        datOdesl: new DateTimeImmutable('now', new DateTimeZone('Europe/Prague')),
        prvniZaslani: true,
        overeni: true, // verification mode – not stored as a sale
    ),
    data: new TrzbaData(
        eicPopl: 'CZ00000019',
        idJednotky: '1',
        idPokl: '1',
        poradCis: '1',
        datTrzby: new DateTimeImmutable('now', new DateTimeZone('Europe/Prague')),
        celkTrzba: 100.0,
    ),
);

$certificate = Certificate::fromPkcs12('/path/to/certificate.p12', 'password');

$result = (new EetClient)->submit(
    $trzba,
    $certificate,
    new ClientOptions(endpoint: EetSchema::PLAYGROUND_ADDRESS),
);

if (!$result->success()) {
    echo "Error: " . $result->errorMessage() . "\n";
}

echo "POK: " . $result->pok() . "\n";
bash
composer