Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
Refactoring, + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
miloshavlicek committed Jul 19, 2016
1 parent e3091f4 commit dcda107
Show file tree
Hide file tree
Showing 25 changed files with 919 additions and 553 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nbproject/*
vendor/
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2016 Miloš Havlíček

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

46 changes: 40 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,52 @@
# Ukázka implementace EET v PHP.
# Example implementation of EET in PHP

## Installation
Install Ondrejnov/eet using [Composer](http://getcomposer.org/):

```sh
$ composer require cothema/eet
```

### Dependencies
PHP >=5.6
robrichards/wse-php

Attached WSDL, key and certificate are intended for non-production usage (Playground).

## Example Usage
Sample codes are located in examples/ folder

### License
MIT

---

# Ukázka implementace EET v PHP

## Instalace
Install Ondrejnov/eet using [Composer](http://getcomposer.org/):

```sh
$ composer require cothema/eet
```

### Závislosti
Testováno na PHP 5.6
PHP >=5.6
robrichards/wse-php

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

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

### Licence
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.
MIT

---

### Reklama
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.

### Bitcoin Donate
1LZuWFUHeVMrYvZWinxFjjkZtuq56TECot

File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "ondrejnov/eet",
"description": "EET (Electronic records of sales for Czech Ministry of Finance) Client for PHP",
"type": "project",
"license": ["MIT", "BSD-3-Clause", "GPL-2.0", "GPL-3.0"],
"require": {
"php": ">=5.6.0",
"robrichards/wse-php": "*"
},
"require-dev": {
"nette/tester": "~1.4"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"classmap": ["src/"]
}
}
108 changes: 108 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 0 additions & 26 deletions example.php

This file was deleted.

10 changes: 10 additions & 0 deletions examples/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

ini_set('display_errors', 1);
define('DIR_ROOT', __DIR__ . '/..');
define('DIR_CERT', DIR_ROOT . '/_cert');
define('DIR_VENDOR', DIR_ROOT . '/vendor');
define('DIR_SRC', DIR_ROOT . '/src');
define('DIR_TEMP', DIR_ROOT . '/temp');

require_once DIR_VENDOR . "/autoload.php";
44 changes: 44 additions & 0 deletions examples/simpleClient/Example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

require_once __DIR__ . "/../bootstrap.php";

use Ondrejnov\EET\Exceptions\ServerException;
use Ondrejnov\EET\Dispatcher;
use Ondrejnov\EET\Receipt;

$dispatcher = new Dispatcher(DIR_CERT . '/eet.key', DIR_CERT . '/eet.pem');

// Example receipt
$r = new Receipt();
$r->uuid_zpravy = 'b3a09b52-7c87-4014-a496-4c7a53cf9120';
$r->dic_popl = 'CZ72080043';
$r->id_provoz = '181';
$r->id_pokl = '1';
$r->porad_cis = '1';
$r->dat_trzby = new \DateTime();
$r->celk_trzba = 1000;

// Valid response should be returned
echo '<h2>---VALID REQUEST---</h2>';
try {
$fik = $dispatcher->send($r); // Send request
echo sprintf('Returned fik code: %s', $fik); // See response - should be returned
} catch (ServerException $e) {
var_dump($e); // See exception
} catch (\Exception $e) {
var_dump($e); // Fatal error
}

// Example of error message
$r->dic_popl = 'x';

// ServerException should be returned
echo '<h2>---ERROR REQUEST---</h2>';
try {
$fik = $dispatcher->send($r); // Send request
var_dump($fik); // See response
} catch (ServerException $e) {
echo sprintf('Error from server of Ministry of Finance: %s', $e->getMessage()); // See exception - should be returned
} catch (\Exception $e) {
var_dump($e); // Fatal error
}
7 changes: 0 additions & 7 deletions lib/EETException.php

This file was deleted.

Loading

0 comments on commit dcda107

Please sign in to comment.