PHP Extension Fatturazione Elettronica Aruba IT: Get by Invoice ID (Sent)

Back to Index

Ricerca una singola fattura per Id

Documentation: https://fatturazioneelettronica.aruba.it/apidoc/docs.html#_getbyinvoiceid

CURL Command

curl -X GET  https://demows.fatturazioneelettronica.aruba.it/services/invoice/out/{invoiceId} \
-H 'Accept: application/json' \
-H 'Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE='

PHP Extension Example

<?php

// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:
include("chilkat_9_5_0.php");

$rest = new CkRest();

//  URL: https://demows.fatturazioneelettronica.aruba.it/services/invoice/out/{invoiceId}
$bTls = true;
$port = 443;
$bAutoReconnect = true;
$success = $rest->Connect('demows.fatturazioneelettronica.aruba.it',$port,$bTls,$bAutoReconnect);
if ($success != true) {
    print 'ConnectFailReason: ' . $rest->get_ConnectFailReason() . "\n";
    print $rest->lastErrorText() . "\n";
    exit;
}

$rest->AddHeader('Authorization','Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=');
$rest->AddHeader('Accept','application/json');

$sbResponseBody = new CkStringBuilder();
$success = $rest->FullRequestNoBodySb('GET','/services/invoice/out/{invoiceId}',$sbResponseBody);
if ($success != true) {
    print $rest->lastErrorText() . "\n";
    exit;
}

$respStatusCode = $rest->get_ResponseStatusCode();
if ($respStatusCode >= 400) {
    print 'Response Status Code = ' . $respStatusCode . "\n";
    print 'Response Header:' . "\n";
    print $rest->responseHeader() . "\n";
    print 'Response Body:' . "\n";
    print $sbResponseBody->getAsString() . "\n";
    exit;
}

$jsonResponse = new CkJsonObject();
$jsonResponse->LoadSb($sbResponseBody);

//  See the Online Tool for Generating JSON Parse Code

$id = $jsonResponse->stringOf('id');
$senderDescription = $jsonResponse->stringOf('sender.description');
$senderCountryCode = $jsonResponse->stringOf('sender.countryCode');
$senderVatCode = $jsonResponse->stringOf('sender.vatCode');
$senderFiscalCode = $jsonResponse->stringOf('sender.fiscalCode');
$receiverDescription = $jsonResponse->stringOf('receiver.description');
$receiverCountryCode = $jsonResponse->stringOf('receiver.countryCode');
$receiverVatCode = $jsonResponse->stringOf('receiver.vatCode');
$receiverFiscalCode = $jsonResponse->stringOf('receiver.fiscalCode');
$invoiceType = $jsonResponse->stringOf('invoiceType');
$docType = $jsonResponse->stringOf('docType');
$file = $jsonResponse->stringOf('file');
$filename = $jsonResponse->stringOf('filename');
$username = $jsonResponse->stringOf('username');
$lastUpdate = $jsonResponse->stringOf('lastUpdate');
$idSdi = $jsonResponse->stringOf('idSdi');
$i = 0;
$count_i = $jsonResponse->SizeOfArray('invoices');
while ($i < $count_i) {
    $jsonResponse->put_I($i);
    $invoiceDate = $jsonResponse->stringOf('invoices[i].invoiceDate');
    $number = $jsonResponse->stringOf('invoices[i].number');
    $status = $jsonResponse->stringOf('invoices[i].status');
    $i = $i + 1;
}


?>

Sample JSON Response Body

{
  "id": "1",
  "sender": {
    "description": "Aruba SPA",
    "countryCode": "ITA",
    "vatCode": "6372762541",
    "fiscalCode": "N5Hnt9vvMZ"
  },
  "receiver": {
    "description": "Aruba SPA",
    "countryCode": "ITA",
    "vatCode": "8767263441",
    "fiscalCode": "LVZTeOJ8BN"
  },
  "invoiceType": "FPA12",
  "docType": "in",
  "file": "ZEdWemRBPT0=",
  "filename": "IT07026037883_jtlkl.xml.p7m",
  "invoices": [
    {
      "invoiceDate": "2019-01-21T17:36:21.289+01:00",
      "number": "1",
      "status": "Inviata"
    },
    {
      "invoiceDate": "2019-01-21T17:36:21.289+01:00",
      "number": "2",
      "status": "Consegnata"
    }
  ],
  "username": "Utente",
  "lastUpdate": "2019-01-21T17:36:21.289+01:00",
  "idSdi": null
}