Following example code describes posting an invoice.
Accessing Sandbox environment
Login:
http://felho.innvoice.hu
apiteszt@innvoice.hu
api312
API keys:
user: apiteszt
pwd: dsjfluio4324hjhjfdhkjskjh213kjgsd
companyname: apiteszt
e.g.: http://api.innvoice.hu/apiteszt/invoice
You can get your API keys from our customer service at hello@innvoice.hu
Sending invoice sample code as follows:
<?php
$data='<invoices>'.
'<invoice>'.
'<CustomerName><![CDATA[John Smith]]></CustomerName>'.
'<CustomerPostcode><![CDATA[1119]]></CustomerPostcode>'.
'<CustomerCity><![CDATA[Budapest]]></CustomerCity>'.
'<CustomerAddress><![CDATA[Test str 2.]]></CustomerAddress>'.
'<CustomerCountry><![CDATA[HU]]></CustomerCountry>'.
'<InvoiceBookID><![CDATA[1]]></InvoiceBookID>'.
'<IssueDate><![CDATA[2016.12.21.]]></IssueDate>'.
'<FulfillmentDate><![CDATA[2016.12.21.]]></FulfillmentDate>'.
'<PaymentDueDate><![CDATA[2016.12.21.]]></PaymentDueDate>'.
'<Currency><![CDATA[HUF]]></Currency>'.
'<PaymentMethod><![CDATA[transfer]]></PaymentMethod>'.
'<items>'.
'<ItemName><![CDATA[Próba tétel]]></ItemName>'.
'<VatKey>27%</VatKey>'.
'<Gross>1</Gross>'.
'<ItemPrice>1200</ItemPrice>'.
'<Quantity>2</Quantity>'.
'<Unit>db</Unit>'.
'</items>'.
'</invoice>'.
'</invoices>';
$params = array(
"data" => urlencode(utf8_encode($data))
);
echo httpPost("http://api.innvoice.hu/companyname/invoice",$params, "user", "pwd");
function httpPost($url,$params, $user, $pwd)
{
$postData = '';
foreach($params as $k => $v)
{
$postData .= $k . '='.$v.'&';
}
$postData = rtrim($postData, '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, $user. ":" .$pwd);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, count($postData));
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$output=curl_exec($ch);
curl_close($ch);
return $output;
}
?>
Comments
0 comments
Please sign in to leave a comment.