コード例 #1
0
ファイル: sample.php プロジェクト: janakthomas/apiclient_cz
<?php

DEFINE('SFAPI_EMAIL', '*****@*****.**');
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' => '*****@*****.**', 'address' => 'John\'s address', 'city' => 'New York', 'zip' => '123 30', 'phone' => '+1 234 567 890'));
//setup invoice data
$api->setInvoice(array('name' => 'My invoice', 'variable' => '123456', 'constant' => '0308', 'specific' => '2012', 'already_paid' => true, '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);
}
コード例 #2
0
ファイル: index.php プロジェクト: janakthomas/apiclient_cz
<?php

require_once 'SFAPIclient/SFAPIclient.php';
// inc. SuperFaktúra PHP-API
$login_email = '*****@*****.**';
// 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);