Contributte Eet
# Content
# Setup
Install package
composer require contributte/eet
1
Register extension
extensions:
eet: Contributte\EET\DI\EETExtension
eet:
certificate:
path: %appDir%/../eet.p12
password: my-password
1
2
3
4
5
6
7
2
3
4
5
6
7
# Configuration
eet:
certificate:
path: %appDir%/../eet.p12
password: my-password
dispatcher:
# Dispatcher setting
service: production / playground
validate: true / false
receipt:
# Set default receipt values
id_pokl: 19903
dic_popl: CZ1234
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
# Usage
# Client usage
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());
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45