PHP code example of contributte / eet
1. Go to this page and download the library: Download contributte/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/ */
contributte / eet example snippets
use Contributte\EET;
use FilipSedivy;
use Nette;
final class SomePresenter extends Nette\Application\UI\Presenter
{
/** @var EET\Dispatcher */
private $client;
/** @var EET\ReceiptFactory */
private $receiptFactory;
public function injectClientFactory(EET\ClientFactory $factory)
{
$this->client = $factory->create();
}
public function injectReceiptFactory(EET\ReceiptFactory $factory)
{
$this->receiptFactory = $factory;
}
public function processPayment()
{
$receipt = $this->receiptFactory->create();
$receipt->porad_cis = '1';
$receipt->celk_trzba = 500;
try {
$this->client->send($receipt);
$this->payment->eet->save_success($this->client->getFik(), $this->client->getPkp());
} catch (FilipSedivy\EET\Exceptions\EET\ClientException $clientException) {
$this->payment->eet->save_error($clientException->getPkp(), $clientException->getBkp());
} catch (FilipSedivy\EET\Exceptions\EET\ErrorException $errorException) {
echo '(' . $errorException->getCode() . ') ' . $errorException->getMessage();
} catch(FilipSedivy\EET\Exceptions\Receipt\ConstraintViolationException $constraintViolationException){
echo implode('<br>', $constraintViolationException->getErrors());
}
}
}