silverback / fattureincloud
FattureInCloud API PHP SDK
1.1.5
2018-07-30 09:59 UTC
Requires
- php: >=5.6
- guzzlehttp/guzzle: ~6.0
- monolog/monolog: ^1.23
- psr/log: ^1.0
Requires (Dev)
- ext-curl: *
- phpunit/phpunit: ^4.0 || ^5.0
- psr/log: ^1.0
Suggests
- psr/log: Required for using the Log middleware
README
Classes are keep updated with the Documentation at https://api.fattureincloud.it/v1/documentation/dist/
You can find your KEYS at https://secure.fattureincloud.it/api
Available API Objects
Each API Method found in the API doc has its Class, here is a list of the currently available ones:
- Svbk\FattureInCloud\Struct\DocDettagliRequest
- Svbk\FattureInCloud\Struct\DocDettagliResponse
- Svbk\FattureInCloud\Struct\DocNuovoArticolo
- Svbk\FattureInCloud\Struct\DocNuovoPagamento
- Svbk\FattureInCloud\Struct\DocNuovoRequest
- Svbk\FattureInCloud\Struct\DocNuovoResponse
- Svbk\FattureInCloud\Struct\InfoListaRequest
- Svbk\FattureInCloud\Struct\InfoListaResponse
more will be available as soon as we have time to map it. Make a PR if you need a missing one.
Usage
Create a simple invoice
use Svbk\FattureInCloud; use Svbk\FattureInCloud\Struct\DocNuovoArticolo as Product; use Svbk\FattureInCloud\Struct\DocNuovoRequest as Invoice; use Svbk\FattureInCloud\Struct\DocNuovoPagamento as Payment; $client = new FattureInCloud\Client( 'API_UID', 'API_KEY' ); $invoiceProduct = new Product( array( 'nome' => 'Product Name', 'prezzo_lordo' => 10, 'cod_iva' => 0, ) ); $payment_date = FattureInCloud\Date::createFromFormat( 'Y-m-d H:i:s', date('Y-m-d H:i:s') ); //now $expire_date = $payment_date; $invoicePayment = new Payment( array( 'data_scadenza' => $expire_date, 'importo' => 'auto', //calculate invoice total automatically 'metodo' => '{{wallet_id}}', //place here your wallet identifier 'data_saldo' => $payment_date, ) ); $newInvoice = new Invoice( array( // New Customer will be created by passing details directly. 'nome' => 'Customer Name', 'indirizzo_via' => 'Customer Address', 'indirizzo_cap' => '50000', //Postal Code 'indirizzo_citta' => 'Customer City', 'indirizzo_provincia' => 'Customer State/Province', 'piva' => 'VATID000000', //vat ID 'cf' => 'FISCALCODEXXXXX', 'paese' => 'Customer Country', //must be obtained via $client->getInfoList( array( 'lista_paesi' ) ); 'lista_articoli' => array( $invoiceProduct ), 'lista_pagamenti' => array( $invoicePayment ), 'prezzi_ivati' => true, // VAT included ) ); $result = $client->createDoc( FattureInCloud\Client::TYPE_FATTURA, $newInvoice ); if ( $result && ! $result->error ) { $invoice_id = $result->new_id; } else { die( sprintf( '[FattureInCloud] Can\'t create invoice. Error: %s', isset($result->error) ? $result->error : '' ) ); }