PHP code example of geniv / nette-eet
1. Go to this page and download the library: Download geniv/nette-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/ */
geniv / nette-eet example snippets
use 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 processPayment()
{
$receipt = $this->receiptFactory->create();
$receipt->porad_cis = '1';
$receipt->celk_trzba = 500;
try {
$client = $this->client->create();
//$client = $this->client->createByCertificate( new CertificateFactory(__DIR__ . '/../../vendor/filipsedivy/php-eet/tests/data/EET_CA1_Playground-CZ00000019.p12', 'eet'));
$client->send($receipt);
$this->payment->eet->save_success($client->getFik(), $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());
}
}
}
json
"php": ">=7.0",
"nette/di": ">=2.4",
"filipsedivy/php-eet": ">=4.2"