PHP code example of composite / invoice-wrapper

1. Go to this page and download the library: Download composite/invoice-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

composite / invoice-wrapper example snippets


use Composite\InvoiceWrapper\Facades\InvoiceWrapper;
use Carbon\Carbon;

$invoicePayload = [
    // Your invoice payload here
];

// Issue the invoice using the selected provider
$invoice = InvoiceWrapper::issueInvoice($invoicePayload);

use Composite\InvoiceWrapper\InvoiceWrapper;
use Carbon\Carbon;

$config = [
    'selected_provider' => env('INVOICING_PROVIDER'),
    'providers' => [
        'billingo' => [
            'name' => 'Billingo',
            'base_url' => env('BILLINGO_BASE_URL', 'https://api.billingo.hu/v3/'),
            'api_key' => env('BILLINGO_API_KEY'),
            'block_id' => env('BILLINGO_BLOCK_ID', 0),
            'waybill_block_id' => env('BILLINGO_WAYBILL_BLOCK_ID', 0),
        ],
        'szamlazzhu' => [
            'name' => 'Szamlazz.hu',
            'api_key' => env('SZAMLAZZHU_API_KEY'),            
            'proforma_prefix'=>env('SZAMLAZZHU_PROFORMA_PREFIX','ORDER'),
        ]
    ],
];

$invoicePayload = [
    // Your invoice payload here
];

// Issue the invoice using the selected provider
$invoiceWrapper = new InvoiceWrapper(
 \Composite\InvoiceWrapper\Factories\InvoiceGatewayFactory::create($config)
);

$invoiceWrapper->issueInvoice($invoicePayload);

$invoicePayload = [
    'partner' => [
        'id' => null, // for billingo y_code' => 'HU',
            'post_code' => '1111',
            'city' => 'Budapest',
            'address' => 'Test utca 1.',
        ],
        'tax_type' => 'NO_TAX_NUMBER', //"HAS_TAX_NUMBER" : "NO_TAX_NUMBER",
        'taxcode' => 'HU29168950',
        'email' => '[email protected]', // if email sending is true it is > 'HUF', // 'HUF', 'EUR'
        'paid' => false,
        'items' => [
            [
                'name' => 'Test product',
                'unit_price' => 1000,
                'unit_price_type' => 'net', // net, gross
                'quantity' => 1,
                'unit' => 'db',
                'vat' => '5', // '0%','5%','18%','27%','27%'
            ],
            [
                'name' => 'Test product 2',
                'unit_price' => 2000,
                'unit_price_type' => 'gross', // net, gross
                'quantity' => 1,
                'unit' => 'db',
                'vat' => '27', // '0%','5%','18%','27%','27%'
            ],
            [
                'name' => 'Test product 3',
                'unit_price' => 2000,
                'unit_price_type' => 'net', // net, gross
                'quantity' => 2,
                'unit' => 'db',
                'vat' => '27', // '0%','5%','18%','27%','27%'
            ]
        ],
        // 'conversion_rate' => 1, // Not handled yet
        'comment' => 'It is a comment',
    ],
];

$invoiceId = 'invoice-id-here';
$invoice = InvoiceWrapper::getInvoice($invoiceId);

$invoiceId = 'invoice-id-here';
$invoice = InvoiceWrapper::downloadInvoice($invoiceId);
bash
php artisan vendor:publish --provider="Composite\InvoiceWrapper\InvoiceWrapperServiceProvider"