Functii API

Listarea / Salvarea Facturilor, Proformelor, Avizelor, Chitante

Metoda de salvare a facturilor, proformelor si avizelor se apeleaza la adresa: https://appv1.facturis-online.ro/facturis/api/print_invoice.php

Iata mai jos modul de apelare al acestei metode

Se face un POST pe pagina cu urmatorii parametrii:

xml_string – textul xml ce contine datele de logare si datele produsului

In cazul in care datele sunt furnizate corect, se returneaza documentul in format pdf

In cazul in care apare o eroare aceasta va fi listata ca in exemplele urmatoare:

Eroare: 10 – Trebuie sa completati seria documentului
Eroare: 11 – Trebuie sa completati numarul documentului

Va prezentam mai jos modul de apelare al acestei metode in PHP:

$xml_string='<?xml version="1.0" encoding="ISO-8859-1"?>
<addInvoice>
  <login>
       <pass>!parola_primita_de_la_facturis_online!</pass>
  </login>   
  <invoice>
      <type>F</type>
      <series>XXXX</series>
      <number>3</number>
	  
      <select_language>2</select_language>
      <select_currency>EUR</select_currency>
	 
  </invoice>
</addInvoice>';
 
 $curl_options = array(
  CURLOPT_URL => "https://appv1.facturis-online.ro/facturis/api/print_invoice.php",
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => "xml_string=$xml_string",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HEADER => false,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CONNECTTIMEOUT => 5
);
 
$curl = curl_init();
curl_setopt_array( $curl, $curl_options );
$result = curl_exec( $curl );

 //daca raspunsul este o eroare
if (strrpos($result, "Eroare") !== false){
  echo $result;
  die;
}
 
  header('Cache-Control: public');
  header('Content-type: application/pdf');
  //daca se doreste salvata
  //header('Content-Disposition: attachment; filename="invoice.pdf"');
  //daca se doreste vizualizata
  header('Content-Disposition: inline; filename="invoice.pdf"');
  header('Content-Length: '.strlen($result));
  echo $result;
  die;

si descrierea tag-urilor XML:

<?xml version="1.0" encoding="ISO-8859-1"?>
<addInvoice>
  <login>
       <pass>!parola_primita_de_la_facturis_online!</pass>
	    <!-- cod unic firma generat din facturis-online.ro - obligatoriu -->
  </login>   
  <invoice>
      <type>F</type>
	  <!-- tipul documentului (F - factura, P - proforma, A - aviz) - obligatoriu -->
      <series>XXXX</series>
	  <!-- seria documentului - obligatoriu -->
      <number>3</number>
	  <!-- numarul documentului - obligatoriu -->
	  
	  
      <select_language>2</select_language>
	  <!-- limba documentului - optional; 1-Romana, 2-Engleza, 3-Franceza, 4-Italiana, 5-Olandeza, 6-Romana/Engleza, 7-Spaniola, 8-Maghiara -->
	 
      <select_currency>RON</select_currency>
	  <!-- moneda documentului - optional; RON, EUR, USD, etc  -->
    
	  
  </invoice>
</addInvoice>

 
Va prezentam mai jos modul de apelare al metode de listare a chitantelor in PHP:


$xml_string='<?xml version="1.0" encoding="ISO-8859-1"?>
<addInvoice>
  <login>
       <pass>!parola_primita_de_la_facturis_online!</pass>
  </login> 
  <getDetails>true</getDetails>  
  <invoice>
      <type>C</type>
      <series>XXXX</series>
      <number>3</number>
      <noOnA4>3</noOnA4>// numar chitante pe A4 		
  </invoice>
</addInvoice>';
 
 $curl_options = array(
  CURLOPT_URL => "https://appv1.facturis-online.ro/facturis/api/print_invoice.php",
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => "xml_string=$xml_string",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HEADER => false,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CONNECTTIMEOUT => 5
);
 
$curl = curl_init();
curl_setopt_array( $curl, $curl_options );
$result = curl_exec( $curl );

 //daca raspunsul este o eroare
if (strrpos($result, "Eroare") !== false){
  echo $result;
  die;
}
 
  header('Cache-Control: public');
  header('Content-type: application/pdf');
  //daca se doreste salvata
  //header('Content-Disposition: attachment; filename="invoice.pdf"');
  //daca se doreste vizualizata
  header('Content-Disposition: inline; filename="invoice.pdf"');
  header('Content-Length: '.strlen($result));
  echo $result;
  die;



0
Ultimele articole RO-eFactura: