Skip to content

Commit dcda107

Browse files
committed
Refactoring, + tests
1 parent e3091f4 commit dcda107

25 files changed

+919
-553
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nbproject/*
2+
vendor/

LICENSE.txt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Miloš Havlíček
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

+40-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,52 @@
1-
# Ukázka implementace EET v PHP.
1+
# Example implementation of EET in PHP
2+
3+
## Installation
4+
Install Ondrejnov/eet using [Composer](http://getcomposer.org/):
5+
6+
```sh
7+
$ composer require cothema/eet
8+
```
9+
10+
### Dependencies
11+
PHP >=5.6
12+
robrichards/wse-php
13+
14+
Attached WSDL, key and certificate are intended for non-production usage (Playground).
15+
16+
## Example Usage
17+
Sample codes are located in examples/ folder
18+
19+
### License
20+
MIT
21+
22+
---
23+
24+
# Ukázka implementace EET v PHP
25+
26+
## Instalace
27+
Install Ondrejnov/eet using [Composer](http://getcomposer.org/):
28+
29+
```sh
30+
$ composer require cothema/eet
31+
```
232

333
### Závislosti
4-
Testováno na PHP 5.6
34+
PHP >=5.6
35+
robrichards/wse-php
536

6-
V adresáří vendor se očekává knihovna https://github.com/robrichards/wse-php
37+
Přiložené WSDL, klíč a certifikát jsou pro neprodukční prostředí (Playground).
738

8-
Přiložené WSDL, klíč a certifikát je pro neprodukční prostředí (Playground).
39+
## Ukázka použití
40+
Ukázky použití naleznete ve složce examples/
941

1042
### Licence
11-
Kód je poskytován tak jak stojí a leží, můžete s ním dělat co chcete, klidně použít i pro EET. Za chyby nezodpovídám.
43+
MIT
44+
45+
---
1246

1347
### Reklama
1448
Komu se nechce do implementace, tak může použít on-line službu <a href="https://www.eetapp.cz/?utm_source=git&utm_medium=link&utm_campaign=eet">EETApp.cz</a>, která má pokročilejší správu účtenek včetně tisku na tiskárnu.
15-
49+
1650
### Bitcoin Donate
1751
1LZuWFUHeVMrYvZWinxFjjkZtuq56TECot
1852

eet.key renamed to _cert/eet.key

File renamed without changes.

eet.pem renamed to _cert/eet.pem

File renamed without changes.

composer.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "ondrejnov/eet",
3+
"description": "EET (Electronic records of sales for Czech Ministry of Finance) Client for PHP",
4+
"type": "project",
5+
"license": ["MIT", "BSD-3-Clause", "GPL-2.0", "GPL-3.0"],
6+
"require": {
7+
"php": ">=5.6.0",
8+
"robrichards/wse-php": "*"
9+
},
10+
"require-dev": {
11+
"nette/tester": "~1.4"
12+
},
13+
"minimum-stability": "dev",
14+
"prefer-stable": true,
15+
"autoload": {
16+
"classmap": ["src/"]
17+
}
18+
}

composer.lock

+108
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example.php

-26
This file was deleted.

examples/bootstrap.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
ini_set('display_errors', 1);
4+
define('DIR_ROOT', __DIR__ . '/..');
5+
define('DIR_CERT', DIR_ROOT . '/_cert');
6+
define('DIR_VENDOR', DIR_ROOT . '/vendor');
7+
define('DIR_SRC', DIR_ROOT . '/src');
8+
define('DIR_TEMP', DIR_ROOT . '/temp');
9+
10+
require_once DIR_VENDOR . "/autoload.php";

examples/simpleClient/Example.php

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
require_once __DIR__ . "/../bootstrap.php";
4+
5+
use Ondrejnov\EET\Exceptions\ServerException;
6+
use Ondrejnov\EET\Dispatcher;
7+
use Ondrejnov\EET\Receipt;
8+
9+
$dispatcher = new Dispatcher(DIR_CERT . '/eet.key', DIR_CERT . '/eet.pem');
10+
11+
// Example receipt
12+
$r = new Receipt();
13+
$r->uuid_zpravy = 'b3a09b52-7c87-4014-a496-4c7a53cf9120';
14+
$r->dic_popl = 'CZ72080043';
15+
$r->id_provoz = '181';
16+
$r->id_pokl = '1';
17+
$r->porad_cis = '1';
18+
$r->dat_trzby = new \DateTime();
19+
$r->celk_trzba = 1000;
20+
21+
// Valid response should be returned
22+
echo '<h2>---VALID REQUEST---</h2>';
23+
try {
24+
$fik = $dispatcher->send($r); // Send request
25+
echo sprintf('Returned fik code: %s', $fik); // See response - should be returned
26+
} catch (ServerException $e) {
27+
var_dump($e); // See exception
28+
} catch (\Exception $e) {
29+
var_dump($e); // Fatal error
30+
}
31+
32+
// Example of error message
33+
$r->dic_popl = 'x';
34+
35+
// ServerException should be returned
36+
echo '<h2>---ERROR REQUEST---</h2>';
37+
try {
38+
$fik = $dispatcher->send($r); // Send request
39+
var_dump($fik); // See response
40+
} catch (ServerException $e) {
41+
echo sprintf('Error from server of Ministry of Finance: %s', $e->getMessage()); // See exception - should be returned
42+
} catch (\Exception $e) {
43+
var_dump($e); // Fatal error
44+
}

lib/EETException.php

-7
This file was deleted.

0 commit comments

Comments
 (0)