Skip to content

marecektn/fakturoid-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Fakturoid PHP lib

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.

Usage

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

Handling errors

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ů)"]}}'
}

Common problems

  • ensure you have certificates for curl present - either globaly in php.ini or call curl_setopt($ch, CURLOPT_CAINFO, "/path/to/cacert.pem")
  • in case of problem please contact our invoicing robot on [email protected]

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%