Beispiel #1
0
<?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);
}
Beispiel #2
0
/*******************************************
 * SFAPI v.: 1.1 example
 *******************************************
 * info@superfaktura.sk
 *******************************************/
DEFINE('SFAPI_EMAIL', '*****@*****.**');
// LOGIN EMAIL TO SUPERFAKTURA
DEFINE('SFAPI_KEY', 'apikey');
// SFAPI KEY
DEFINE('SFAPI_MODULE', 'API');
// TITLE OF MODULE FE. 'WOOCOMMERCE MODULE'
DEFINE('SFAPI_APPTITLE', 'Example API application');
// TITLE OF YOUR APPLICATION FE. 'SUPERFAKTURA.SK'
require_once '../SFAPIclient/SFAPIclient.php';
// Create and init SFAPIclient
$api = new SFAPIclient(SFAPI_EMAIL, SFAPI_KEY, SFAPI_APPTITLE, SFAPI_MODULE);
/***********************************************
 * Example; create new invoice
 ***********************************************/
// 1) set Client
$api->setClient(array('name' => 'Example s.r.o.', 'phone' => '+421000000000', 'email' => '*****@*****.**'));
// 2) set Invoice
$api->setInvoice(array('name' => 'Invoice example', 'variable' => '123456', 'due' => date('Y-m-d', strtotime("+20 day")), 'already_paid' => true));
// 3) add new Invioce item
$api->addItem(array('name' => 'Example item', 'descriptions' => 'Description of "Example item"', 'unit_price' => 20, 'tax' => 20, 'quantity' => 5, 'discount' => 50, 'discount_description' => 'Discount 50% COUPON: AA11BB22CC33'));
// 4) save data
$response = $api->save();
if (!empty($bench)) {
    _debug($response, 'Create new invoice example');
}
/********************************************
<?php

// Create new contact person for existing client
require_once '../SFAPIclient/SFAPIclient.php';
$email = '*****@*****.**';
$token = 'apitoken';
$api = new SFAPIclient($email, $token);
$data = array('client_id' => 503084, 'name' => 'Jaroslav', 'email' => '*****@*****.**');
$result = $api->addContactPerson($data);
if ($result->state === 'SUCCESS') {
    echo 'Contact person saved. ID: ' . $result->data->ContactPerson->id;
} else {
    echo 'Error saving contact person: ' . $result->message;
}
Beispiel #4
0
<?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);