PHP code example of slevomat / eet-client

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

    

slevomat / eet-client example snippets


$crypto = new CryptographyService('cesta k privátnímu klíči', 'cesta k veřejnému klíči', 'heslo privátního klíče (nebo prázdný string pokud bez hesla)');
$configuration = new Configuration(
    'DIČ poplatníka',
    'Identifikace provozovny ',
    'Identifikace pokladního zařízení',
    EvidenceEnvironment::get(EvidenceEnvironment::PLAYGROUND), // nebo EvidenceEnvironment::get(EvidenceEnvironment::PRODUCTION) pro komunikaci s produkčním systémem
    false // zda zasílat účtenky v ověřovacím módu
);
$client = new Client($crypto, $configuration, new GuzzleSoapClientDriver(new \GuzzleHttp\Client()));

$receipt = new Receipt(
	true,
	'CZ683555118',
	'0/6460/ZQ42',
	new \DateTimeImmutable('2016-11-01 00:30:12'),
    3411300
);

try {
    $response = $client->send($receipt);
    echo $response->getFik();
} catch (\SlevomatEET\FailedRequestException $e) {
    echo $e->getRequest()->getPkpCode(); // if request fails you need to print the PKP and BKP codes to receipt
} catch (\SlevomatEET\InvalidResponseReceivedException $e) {
    echo $e->getResponse()->getRequest()->getPkpCode(); // on invalid response you need to print the PKP and BKP too
}