1. Go to this page and download the library: Download fakturan.nu/fakturan 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/ */
// Find your client
$client = Fakturan\Client::find(1);
$invoice = new Fakturan\Invoice();
$invoice->client_id = $client->id;
$invoice->date = date('Y-m-d');
// Find a product to use for templating
$product = Fakturan\Product::find(24);
// Add the product to the invoice. The second parameter can override the default values.
// It is used to set the amount and makes it possible to add a discount.
// See https://fakturan.nu/apidocs/2/invoices/create.html for possible attributes on rows.
$invoice->addRow($product, ['amount' => 5]);
// It is also possible to add rows without a preset product by sending an array instead:
$row = [
'product_name' => 'My custom product',
'unit' => 'PCS',
'price' => 500,
'amount' => 24
];
$invoice->addRow($row)
// Rows only consisting of text can also be added
$invoice->addRow(['text_row' => true, 'text' => 'Performed customizations: purple flames']);
$invoice->save();
Fakturan\Error\AccessDenied // Catches 401 (access denied)
Fakturan\Error\ResourceNotFound // Catches 404 (Resource not found).
Fakturan\Error\ConnectionFailed // Catches 407 (Connection to server failed).
Fakturan\Error\ResourceInvalid // Catches 422 (Validation errors).
Fakturan\Error\ClientError // Catches 400-499 (Client errors).
Fakturan\Error\ServerError // Catches 500-599 (Server related issues).
Fakturan\Error\FakturanException // Catches all of the above
try {
// Methods that sends a request to the server
}
catch(Fakturan\Error\FakturanException $e)
{
echo $e->getMessage();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.