forked from superfaktura/apiclient_cz
/
index.php
39 lines (36 loc) · 1015 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
require_once('SFAPIclient/SFAPIclient.php'); // inc. SuperFaktúra PHP-API
$login_email = 'chriastel.lubomir@gmail.com'; // moja.superfaktura.sk login email
$api_token = '702b3498dcfeb7773ed54d31e90adaa2'; // token from my account
$sf_api = new SFAPIclient($login_email, $api_token); // create SF PHP-API object
// set client for new invoice
$sf_api->setClient(array(
'name' => 'MyClient',
'address' => 'MyClient address 1',
'zip' => 12345,
'city' => 'MyClientCity'
));
// set invoice attributes
$sf_api->setInvoice(array(
'name' => 'MyInvoice',
'bank_accounts' => array(
array(
'bank_name' => 'FIO',
'account' => '0025164895',
'bank_code' => '1234',
'iban' => 'SK0000000000000000',
'swift' => '12345',
)
),
));
// add new invoice item
$sf_api->addItem(array(
'name' => 'MyInvoiceItem',
'description' => 'Inv. item no. 1',
'unit_price' => 10,
'tax' => 20
));
// save invoice in SuperFaktura
$json_response = $sf_api->save();
// TODO: handle exceptions
//var_dump($json_response);