PHP code example of gabrielecorio / fiscozen-wrapper
1. Go to this page and download the library: Download gabrielecorio/fiscozen-wrapper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gabrielecorio / fiscozen-wrapper example snippets
use GabrieleCorio\FiscozenWrapper\FiscozenClient;
use GabrieleCorio\FiscozenWrapper\Exceptions\AuthenticationException;
$client = new FiscozenClient(
email: '[email protected]',
password: 'your-password',
sessionDir: '/path/to/sessions', // optional; defaults to sys_get_temp_dir()/fiscozen_sessions
);
// --- Request 1: submit credentials ---
try {
$phoneNumber = $client->startLogin(); // returns the masked phone number
// Store $phoneNumber in your session and show the OTP input to the user
} catch (AuthenticationException $e) {
// handle error
}
// --- Request 2: submit OTP ---
try {
$client->submitOtp($otpFromUser);
} catch (AuthenticationException $e) {
// handle error
}
$client->login(function (string $phoneNumber): string {
echo "OTP sent to {$phoneNumber}: ";
return trim(fgets(STDIN));
});
$client->isAuthenticated(); // bool — makes a lightweight API call to verify the session
$client->logout(); // deletes the cookie file and invalidates the local session
$client->relogin($callback); // destroys the existing session and authenticates again
$invoices = $client->invoices()->list(
page: 1,
pageSize: 20,
selfInvoice: false,
);
foreach ($invoices->results as $invoice) {
// Read the fields needed by your application.
}
// Invoices issued to a customer in a period (most recent first by default).
$issued = $client->invoices()->list(
counterpart: 1239628,
dateFrom: new DateTimeImmutable('2026-06-01'),
dateTo: new DateTimeImmutable('2026-10-31'),
pageSize: 50,
);
// No match returns count 0 and an empty `results`, not an error.
// Or find the customer by name, surname or business name.
$issued = $client->invoices()->list(counterpartSearch: 'Rossi');
// Invoice details by number and year (e.g. 24/2026), no internal ID needed.
try {
$invoice = $client->invoices()->findByNumber(number: 24, year: 2026);
echo $invoice['full_id'], ' ', $invoice['amount'], ' ', $invoice['status'];
$rows = $invoice['data']['rows']; // description, quantity, amount, total, vat_code
} catch (InvoiceNotFoundException $e) {
// "Invoice not found: 24/2026"
}
// Or by internal Fiscozen ID.
$invoice = $client->invoices()->get(6512587);
$formatInfo = $client->invoices()->getFormatInfo(
new DateTimeImmutable('2026-01-15'),
);