-
Notifications
You must be signed in to change notification settings - Fork 10
/
example.php
45 lines (36 loc) · 1.07 KB
/
example.php
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
<?php
require_once('Fiskalizator.php');
//Init XML
$doc = new DOMDocument();
$doc->formatOutput = true;
$xml_string = file_get_contents('racun.xml');
$doc->loadXML($xml_string);
$fis = new Fiskalizator('certificates/demo/my_private.pfx', 'pass');
#UNCOMMENT FOLLOWING LINE AFTER YOU THOROUGHLY TESTED DEMO MODE (service provider says 2 days minimum)
#$fis->setProductionMode();
#Also, do not forget to change certPath and certPass to match your production certificate
try {
$fis->doRequest($doc);
#custom timeout and number of retries on network error, default is 3 retries and 5 seconds timeout tolerance
#$fis->doRequest($doc, 10, 5.2);
} catch (Exception $e) {
echo $e->getMessage();
die();
}
echo 'Success<br>';
if ($fis->getRequestType() == 'RacunZahtjev'){
echo 'JIR: '.$fis->getJIR().'<br>';
echo 'ZKI: '.$fis->getZKI().'<br>';
}
/**
* For those without auto complete :)
*
var_dump(
$fis->getRequestType(),
$fis->getResponseType(),
$fis->getRequest(),
$fis->getResponse(),
$fis->getRawRequest(),
$fis->getRawResponse()
);
*/