This is a simple Laravel (PHP) wrapper for Billingo (billingo.hu) API V3 SwaggerHUB PHP SDK.
Compatible with: Laravel 6.x (LTS), Laravel 7.x and Laravel 8.x or PHP 7.0<
You can use the wrapper freely with all type of PHP projects (not just Laravel) from 1.0.0 version without changing except downloadInvoice method.
v1.1
- Implement or rewrite downloadInvoice for native PHP use.
You can install the package via composer or just download it:
composer require deviddev/billingo-api-v3-wrapper:^1.0Publish config file:
php artisan vendor:publish --provider=Deviddev\BillingoApiV3Wrapper\BillingoApiV3WrapperServiceProvider
First set up your Billingo API V3 key in ./config/billingo-api-v3-wrapper.php config file.
Import wrapper with facade:
use BillingoApiV3Wrapper as BillingoApi;Import wrapper:
use Deviddev\BillingoApiV3Wrapper\BillingoApiV3Wrapper as BillingoApi;You must add your api key to BillingoApi object constructor:
$billingoApi = new BillingoApi('YOUR_API_KEY_HERE');Make an api instance (eg.: BankAccount, Currency, Document, DocumentBlock, DocumentExport, Organization, Partner, Product, Util):
api(string $apiName);Add some data to model:
make(array $data);Make a model instance (eg: Address, BankAccount, Currency, Document, etc... - see in ./vendor/deviddev/billingo-api-v3-php-sdk/lib/model):
model(string $modelName, array $data = null);(if you don't want use make() method simply add necessary data as second parameter)
With http info (get http info (headers, response code, etc...)):
withHttpInfo();Get invoice, partner, product(call api class method with model instance):
get(int $id);Delete partner, product (call api class method with model instance):
delete(int $id);Delete payment (call api class method with model instance):
deletePayment(int $id);Create model (call api class method with model instance):
create();Update model (call api class method with model instance and model id):
update(int $id);Cancel invoice:
cancelInvoice(int $invoiceId);Create invoice from proforma invoice:
createInvoiceFromProforma(int $invoiceId);Check tax number:
checkTaxNumber(string $taxNumber);List model (call api class method with model instance):
list(array $conditions);*** All conditions is optional!
Download invoice to server:
downloadInvoice(int $invoiceId, string $path = null, string $extension = null);Send invoice in email:
sendInvoice(int $invoiceId);Get invoice public url response:
getPublicUrl(int $id);Get Billingo API response:
getResponse();Get Billingo API response id (eg.: partner id, invoice id, etc.):
getId();All pulic methods are chainable, except getResponse() and getId() methods.
If you don't add some data to model(string $modelName, array $data = null) method second array $data = null parameter, you MUST use make(array $data) method BEFORE model() method, see in examples.
The withHttpInfo() method MUST be called IMMEDIATELY AFTER the api(), make() or model() methods.
Partner array:
$partner = [
'name' => 'Test Company',
'address' => [
'country_code' => 'HU',
'post_code' => '1010',
'city' => 'Budapest',
'address' => 'Nagy Lajos 12.',
],
'emails' => ['test@company.hu'],
'taxcode' => '',
];Create partner and get response:
BillingoApi::api('Partner')->model('PartnerUpsert', $partner)->create()->getResponse();OR
Create partner with make and get response:
BillingoApi::api('Partner')->make($partner)->model('PartnerUpsert')->create()->getResponse();OR
Create partner and get partner id:
BillingoApi::api('Partner')->model('PartnerUpsert', $partner)->create()->getId();OR
Create partner with make and get partner id:
BillingoApi::api('Partner')->make($partner)->model('PartnerUpsert')->create()->getId();Create partner and get response:
$billingoApi->api('Partner')->model('PartnerUpsert', $partner)->create()->getResponse();OR
Create partner with make and get response:
$billingoApi->api('Partner')->make($partner)->model('PartnerUpsert')->create()->getResponse();OR
Create partner and get partner id:
$billingoApi->api('Partner')->model('PartnerUpsert', $partner)->create()->getId();OR
Create partner with make and get partner id:
$billingoApi->api('Partner')->make($partner)->model('PartnerUpsert')->create()->getId();Partner array:
$partner = [
'name' => 'Test Company updated',
'address' => [
'country_code' => 'HU',
'post_code' => '1010',
'city' => 'Budapest',
'address' => 'Nagy Lajos 12.',
],
'emails' => ['test@company.hu'],
'taxcode' => '',
];Update partner and get response:
BillingoApi::api('Partner')->model('Partner', $partner)->update('BILLINGO_PARTNER_ID')->getResponse();OR
Update partner with make and get response:
BillingoApi::api('Partner')->make($partner)->model('Partner')->update('BILLINGO_PARTNER_ID')->getResponse();OR
Update partner and get partner id:
BillingoApi::api('Partner')->model('Partner', $partner)->update('BILLINGO_PARTNER_ID')->getId();OR
Update partner with make and get partner id:
BillingoApi::api('Partner')->make($partner)->model('Partner')->update('BILLINGO_PARTNER_ID')->getId();Update partner and get response:
$billingoApi->api('Partner')->model('Partner', $partner)->update('BILLINGO_PARTNER_ID')->getResponse();OR
Update partner with make and get response:
$billingoApi->api('Partner')->make($partner)->model('Partner')->update('BILLINGO_PARTNER_ID')->getResponse();OR
Update partner and get partner id:
$billingoApi->api('Partner')->model('Partner', $partner)->update('BILLINGO_PARTNER_ID')->getId();OR
Update partner with make and get partner id:
$billingoApi->api('Partner')->make($partner)->model('Partner')->update('BILLINGO_PARTNER_ID')->getId();Invoice array:
$invoice = [
'partner_id' => BILLINGO_PARTNER_ID, // REQUIRED int
'block_id' => YOUR_BILLINGO_BLOCK_ID, // REQUIRED int
'bank_account_id' => YOUR_BILLINGO_BANK_ACCOUNT_ID, // int
'type' => 'invoice', // REQUIRED
'fulfillment_date' => Carbon::now('Europe/Budapest')->format('Y-m-d'), // REQUIRED, set up other time zone if it's necessaray
'due_date' => Carbon::now('Europe/Budapest')->format('Y-m-d'), // REQUIRED, set up other time zone if it's necessaray
'payment_method' => 'online_bankcard', // REQUIRED, see other types in billingo documentation
'language' => 'hu', // REQUIRED, see others in billingo documentation
'currency' => 'HUF', // REQUIRED, see others in billingo documentation
'conversion_rate' => 1, // see others in billingo documentation
'electronic' => false, // see others in billingo documentation
'paid' => false, // see others in billingo documentation
'items' => [
[
'name' => 'Laptop', // REQUIRED
'unit_price' => '100000', // REQUIRED
'unit_price_type' => 'gross', // REQUIRED
'quantity' => 2, // REQUIRED int
'unit' => 'db', // REQUIRED
'vat' => '27%', // REQUIRED
'comment' => 'some comment here...',
],
],
'comment' => 'some comment here...',
'settings' => [
'mediated_servicíe' => false,
'without_financial_fulfillment' => false,
'online_payment' => '',
'round' => 'five',
'place_id' => 0,
],
];Create invoice and get response:
BillingoApi::api('Document')->model('DocumentInsert', $invoice)->create()->getResponse();OR
Create invoice with make and get response:
BillingoApi::api('Document')->make($invoice)->model('DocumentInsert')->create()->getResponse();OR
Create invoice and get invoice id:
BillingoApi::api('Document')->model('DocumentInsert', $invoice)->create()->getId();OR
Create invoice with make and get invoice id:
BillingoApi::api('Document')->make($invoice)->model('DocumentInsert')->create()->getId();Create invoice and get response:
$billingo->api('Document')->model('DocumentInsert', $invoice)->create()->getResponse();OR
Create invoice with make and get response:
$billingo->api('Document')->make($invoice)->model('DocumentInsert')->create()->getResponse();OR
Create invoice and get invoice id:
$billingo->api('Document')->model('DocumentInsert', $invoice)->create()->getId();OR
Create invoice with make and get invoice id:
$billingo->api('Document')->make($invoice)->model('DocumentInsert')->create()->getId();List invoices:
BillingoApi::api('Document')->list([
'page' => 1,
'page' => 25,
'block_id' => 42432,
'partner_id' => 13123123,
'payment_method' => 'cash',
'payment_status' => 'paid',
'start_date'] => '2020-05-10',
'end_date' => '2020-05-15',
'start_number' => '1',
'end_number' => '10',
'start_year' => 2020,
'end_year'] => 2020
])->getResponse();List partners:
BillingoApi::api('Partner')->list([
'page' => 1,
'per_page' => 5
])->getResponse();List blocks:
BillingoApi::api('DocumentBlock')->list([
'page' => 1,
'per_page' => 5
])->getResponse();List banks accounts:
BillingoApi::api('BankAccount')->list([
'page' => 1,
'per_page' => 5
])->getResponse();List products:
BillingoApi::api('Products')->list([
'page' => 1,
'per_page' => 5
])->getResponse();List invoices:
$billingoApi->api('Document')->list([
'page' => 1,
'page' => 25,
'block_id' => 42432,
'partner_id' => 13123123,
'payment_method' => 'cash',
'payment_status' => 'paid',
'start_date'] => '2020-05-10',
'end_date' => '2020-05-15',
'start_number' => '1',
'end_number' => '10',
'start_year' => 2020,
'end_year'] => 2020
])->getResponse();List partners:
$billingoApi->api('Partner')->list([
'page' => 1,
'per_page' => 5
])->getResponse();List blocks:
$billingoApi->api('DocumentBlock')->list([
'page' => 1,
'per_page' => 5
])->getResponse();List banks accounts:
$billingoApi->api('BankAccount')->list([
'page' => 1,
'per_page' => 5
])->getResponse();List products:
$billingoApi->api('Products')->list([
'page' => 1,
'per_page' => 5
])->getResponse();Default path is: ./storage/app/invoices
Default extension is: .pdf
File name is invoice id.
Return the path in the response, eg.:
path: "invoices/11246867.pdf"Download invoice:
BillingoApi::api('Document')->downloadInvoice(INVOICE_ID)->getResponse();OR
Download to specified path and extension:
BillingoApi::api('Document')->downloadInvoice(INVOICE_ID, 'PATH', 'EXTENSION')->getResponse();Come in version 1.1.
Return the e-mails array where to send the invoce, eg.:
emails: [
"kiss@kft.hu"
]Send invoice:
BillingoApi::api('Document')->sendInvoice(INVOICE_ID)->getResponse();Send invoice:
$billingoApi->api('Document')->sendInvoice(INVOICE_ID)->getResponse();Return the public url array, eg.:
[
public_url: "https://api.billingo.hu/document-access/K3drE0Gvb2eRwQNYlypfasdOlJADB4Y"
]Get invoice public url:
BillingoApi::api('Document')->getPublicUrl(INVOICE_ID)->getResponse();Get invoice public url:
$billingoApi->api('Document')->getPublicUrl(INVOICE_ID)->getResponse();Cancel invoice:
BillingoApi::api('Document')->cancelInvoice(INVOICE_ID)->getResponse();Cancel invoice:
$billingoApi->api('Document')->cancelInvoice(INVOICE_ID)->getResponse();Create invoice from proforma invoice:
BillingoApi::api('Document')->createInvoiceFromProforma(INVOICE_ID)->getResponse();Create invoice from proforma invoice:
$billingoApi->api('Document')->createInvoiceFromProforma(INVOICE_ID)->getResponse();First set up your NAV connection in your billingo account, because it always return "Invalid tax number!"
Check tax number:
BillingoApi::api('Util')->checkTaxNumber('tax_number')->getResponse();Check tax number:
$billingoApi->api('Util')->checkTaxNumber('tax_number')->getResponse();Get invoice:
BillingoApi::api('Document')->get(INVOICE_ID)->getResponse();Get partner:
BillingoApi::api('Partner')->get(PARTNER_ID)->getResponse();Get product:
BillingoApi::api('Product')->get(PRODUCT_ID)->getResponse();Get invoice:
$billingoApi->api('Document')->get(INVOICE_ID)->getResponse();Get partner:
$billingoApi->api('Partner')->get(PARTNER_ID)->getResponse();Get product:
$billingoApi->api('Product')->get(PRODUCT_ID)->getResponse();Delete partner:
BillingoApi::api('Partner')->delete(PARTNER_ID)->getResponse();Delete product:
BillingoApi::api('Product')->get(PRODUCT_ID)->getResponse();Delete partner:
$billingoApi->api('Partner')->delete(PARTNER_ID)->getResponse();Delete product:
$billingoApi->api('Product')->get(PRODUCT_ID)->getResponse();Get partner:
BillingoApi::api('Partner')->deletePayment(PAYMENT_ID)->getResponse();Get partner:
$billingoApi->api('Partner')->deletePayment(PAYMENT_ID)->getResponse();With http info:
BillingoApi::api('Product')->withHttpInfo()->list(['page' => 1, 'per_page' => 5])->getResponse();With http info:
$billingoApi->api('Product')->withHttpInfo()->list(['page' => 1, 'per_page' => 5])->getResponse();First set up your Billingo API V3 Key in config/config.php file.
Linux, MAC OS
$ ./vendor/bin/phpunit
OR
$ composer test
Windows
$ vendor\bin\phpunit
OR
$ composer test-win
Please see CONTRIBUTING for details.
If you discover any security related issues, please email david.molnar.mega@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.