PHP library for Fakturoid.cz. Please see API for more documentation. New account just for testing API and using separate user (created via "Nastavení > Uživatelé a oprávnění") for production usage is higly recommended.
require_once '/path/to/lib/Fakturoid.php';
$f = new Fakturoid('..slug..', '[email protected]..', '..api_key..', 'PHPlib <[email protected]>');
// create subject
$subject = $f->create_subject(array('name' => 'Firma s.r.o.', 'email' => '[email protected]'));
// create invoice with lines
$lines = array(array('name' => 'Big sale', 'quantity' => 1, 'unit_price' => 1000));
$invoice = $f->create_invoice(array('subject_id' => $subject->id, 'lines' => $lines));
// send created invoice
$f->fire_invoice($invoice->id, 'deliver');
// to mark invoice as paid
$f->fire_invoice($invoice->id, 'pay'); // or 'pay_proforma' for paying proforma and 'pay_partial_proforma' for partial proforma
Library raises FakturoidException
if server returns code 4xx
or 5xx
. You can get response code and response body by calling getCode()
or getMessage()
.
try {
$subject = $f->create_subject(array('name' => '', 'email' => '[email protected]'));
} catch (FakturoidException $e) {
$e->getCode(); // 422
$e->getMessage(); // '{"errors":{"name":["je povinná položka","je příliš krátký/á/é (min. 2 znaků)"]}}'
}
- ensure you have certificates for curl present - either globaly in
php.ini
or callcurl_setopt($ch, CURLOPT_CAINFO, "/path/to/cacert.pem")
- in case of problem please contact our invoicing robot on [email protected]