Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
nticaric committed Oct 9, 2023
1 parent 6a17d3b commit c44c448
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ $bill->setNoteOfRedelivary(false);
$billRequest = new BillRequest($bill);

$soapMessage = $fis->signXML($billRequest->toXML());
$res = $fis->sendSoap($soapMessage);
var_dump($res);
$response = $fis->sendSoap($soapMessage);

$parser = new ResponseParser($response);
$jir = $parser->getJir();
var_dump($jir);
```

### OpenSSL 3
Expand Down
1 change: 1 addition & 0 deletions src/Fiskalizacija.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Fiskalizacija
private $url = "https://cis.porezna-uprava.hr:8449/FiskalizacijaService";
private $privateKeyResource;
private $publicCertificateData;
private $signedInfoSignature;

public function __construct($path, $pass, $security = 'SSL', $demo = false)
{
Expand Down
31 changes: 31 additions & 0 deletions src/ResponseParse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php namespace Nticaric\Fiskalizacija;

use DOMDocument;
use DOMXPath;
use Exception;

class ResponseParser
{
private $document;
private $xpath;

public function __construct($response)
{
$this->document = new DOMDocument();
$this->document->loadXML($response);
$this->xpath = new DOMXPath($this->document);
// Register the namespaces used in the SOAP response
$this->xpath->registerNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/');
$this->xpath->registerNamespace('tns', 'http://www.apis-it.hr/fin/2012/types/f73');
}

public function getJir()
{
$query = '/soap:Envelope/soap:Body/tns:RacunOdgovor/tns:Jir';
$entries = $this->xpath->query($query);
if ($entries->length > 0) {
return $entries->item(0)->nodeValue;
}
throw new Exception('JIR value not found in the response');
}
}

0 comments on commit c44c448

Please sign in to comment.