Prva stran 
Nazaj 
Naprej 
Novosti 
 Kopiraj povezavo na to stran 
 
Natisni stranNatisni stran  
e-računi navodila za up...  >  Spletne storitve in int...  >  API Examples  >  API Examples in PHP

API Examples in PHP

SalesInvoiceGet

For this PHP code to work you first need Curl library installed.
This example gets sales invoice by document number. Request is in XML format. This request can be replaced by any of the xml examples in API Reference.

Parameters and explanation
Server url is https://eurofaktura.com/WebServicesSI/API.
In header you put content type which is application/xml
Post field must contain the request in XML format as seen bellow.
After we execute this request we have to convert the response to XML format.
Methods curl_errno and curl_error are used for error handling.

Example request and response

<?php
<!-- request in XML format -->
       $string = '<?xml version="1.0" encoding="UTF-8"?>
       <request>
       <login username="micka" md5pass="ddb43e9f119c6805f4770ecc4f6466ba" token="C71FF0048D3E0D0083301B8B06309270" />
<method name="SalesInvoiceGet">
       <parameter name="number" value="100/1/171" />
</method>
       </request>';

<!-- Executing request with curl -->
       $serverUrl = "https://eurofaktura.com/WebServicesSI/API";
       $ch = curl_init($serverUrl);
       curl_setopt($ch, CURLOPT_HEADER, ("Content-Type: application/xml"));
       curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
       $data = htmlentities(curl_exec($ch));
       
       $curl_errno = curl_errno($ch);
       $curl_error = curl_error($ch);

       curl_close($ch);
       if ($curl_errno > 0) {
               echo ('cURL Error ($curl_errno): $curl_error\n');
               exit;
       } else {
               echo ($data);
       }
       exit;
?>

RESPONSE
<?xml version="1.0" encoding="utf-8"?>

<!--
       Generated by www.e-racuni.com

       Release number: 717.2
       Release date: 06.10.2017
       Request URL: /WebServicesSI/API
-->

<response status="ok">
       <SalesInvoice>
               <advanceInvoicesRef></advanceInvoicesRef>
               <amountAlreadyPaid>0</amountAlreadyPaid>
               <amountLeftToBePaid>610</amountLeftToBePaid>
               <bankAccountNumber>SI56 0451 5000 0115 162</bankAccountNumber>
               <businessUnit>0001</businessUnit>
               <businessYear>2016</businessYear>
               <buyerCity>Ljubljana</buyerCity>
               <buyerCountry>SI</buyerCountry>
               <buyerEMail></buyerEMail>
               <buyerName>PARTNER D.O.O.</buyerName>
               <buyerPostalCode>1000</buyerPostalCode>
               <buyerStreet>Test 300</buyerStreet>
               <buyerVatRegistration>Unknown</buyerVatRegistration>
               <city>Maribor</city>
               <costPosition></costPosition>
               <creditNotesRef></creditNotesRef>
               <date>2017-03-07</date>
               <dateOfSupplyFrom>2017-03-07</dateOfSupplyFrom>
               <debitNotesRef></debitNotesRef>
               <deliveryNotesRef></deliveryNotesRef>
               <expirationDate>2017-03-08</expirationDate>
               <fiscalNumber>100/1/171</fiscalNumber>
               <isReccurringInvoice>false</isReccurringInvoice>
               <issuedTimestamp>9:26</issuedTimestamp>
               <issuedTimestampDate>2017-03-07</issuedTimestampDate>
               <methodOfPayment>BankTransfer</methodOfPayment>
               <number>100/1/171</number>
               <paymentDueDate>2017-03-08</paymentDueDate>
               <reference>99</reference>
               <referenceUPN>SI12 0010011713801</referenceUPN>
               <salesOrdersRef></salesOrdersRef>
               <status>IssuedInvoice</status>
               <totalAmount>610</totalAmount>
               <totalCurrency>EUR</totalCurrency>
               <totalDiscount>0</totalDiscount>
               <totalNetAmount>500</totalNetAmount>
               <totalVatAmountFlatRate>0</totalVatAmountFlatRate>
               <totalVatAmountLowerRate>0</totalVatAmountLowerRate>
               <totalVatAmountNormalRate>110</totalVatAmountNormalRate>
               <totalVatAmountZeroRate>0</totalVatAmountZeroRate>
               <totalVatBaseAmountFlatRate>0</totalVatBaseAmountFlatRate>
               <totalVatBaseAmountLowerRate>0</totalVatBaseAmountLowerRate>
               <totalVatBaseAmountNormalRate>500</totalVatBaseAmountNormalRate>
               <totalVatBaseAmountZeroRate>0</totalVatBaseAmountZeroRate>
               <type>Gross</type>
               <vatTransactionType>0</vatTransactionType>
               <warehouseCode>0000</warehouseCode>
               <wayOfPayment>BankTransfer</wayOfPayment>
               <Items>
                       <Item>
                               <amount>500</amount>
                               <amountWithoutDiscount>500</amountWithoutDiscount>
                               <costPosition></costPosition>
                               <currency>EUR</currency>
                               <description>test</description>
                               <discountAmount>0</discountAmount>
                               <discountPercentage>0</discountPercentage>
                               <netPrice>500</netPrice>
                               <netPriceInDocumentCurrency>500</netPriceInDocumentCurrency>
                               <position>1</position>
                               <price>610</price>
                               <priceInDocumentCurrency>610</priceInDocumentCurrency>
                               <quantity>1</quantity>
                               <totalDiscountPercentage>0</totalDiscountPercentage>
                               <unit></unit>
                               <vatAmount>110</vatAmount>
                               <vatPercentage>22</vatPercentage>
                       </Item>
               </Items>
       </SalesInvoice>
</response>



PHP_Examples.zip
Velikost: 9,89 kB

---
Zadnja sprememba 20.02.2019 11:21:28
© E-RAČUNI d.o.o. 2003-2024