forked from superfaktura/apiclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.php
56 lines (48 loc) · 1.55 KB
/
sample.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
DEFINE('SFAPI_EMAIL', '[email protected]');
DEFINE('SFAPI_KEY', 'apikey');
require_once('SFAPIclient/SFAPIclient.php');
$api = new SFAPIclient(SFAPI_EMAIL, SFAPI_KEY);
//setup client data
$api->setClient(array(
'name' => 'John Doe',
'ico' => '12345678',
'dic' => '12345678',
'ic_dph' => 'SK12345678',
'email' => '[email protected]',
'address' => 'John\'s address',
'city' => 'New York',
'zip' => '123 30',
'phone' => '+1 234 567 890',
));
//setup invoice data
$api->setInvoice(array(
//all items are optional, if not used, they will be filled automatically
'name' => 'My invoice',
'variable' => '123456', //variable symbol / reference
'constant' => '0308', //constant symbol
'specific' => '2012', //specific symbol
'already_paid' => true, //has the invoices been already paid?
'comment' => 'My comment',
));
//add invoice item, this can be called multiple times
//if you are not a VAT registered, use tax = 0
$api->addItem(array(
'name' => 'Superfaktura.sk',
'description' => 'Subscriptions',
'quantity' => 1,
'unit' => 'ks',
'unit_price' => 40.83,
'tax' => 20
));
//save invoice
$response = $api->save();
// response object contains data about created invoices, or error messages respectively
if($response->error === 0){
//complete information about created invoice
var_dump($response->data);
} else {
//error descriptions
var_dump($response->error_message);
}
?>