/yii2-infakt

Primary LanguagePHPMIT LicenseMIT

yii2-infakt

Infakt component for Yii 2 framework

inFakt API Documentation

Installation

The preferred way to install this extension is through composer.

Run

composer require "mrstroz/yii2-infakt" "*"

or add

"mrstroz/yii2-infakt": "*"

to the require section of your composer.json file.

Usage

  1. Add component to your config file
'components' => [
    // ...
    'infakt' => [
        'class' => 'mrstroz\infakt\Infakt',
        'apiKey' => 'xxxxxx',
    ],
]
  1. Add new client
/** @var Infakt $inFakt */
$inFakt = Yii::$app->infakt;
$response = $inFakt->call('clients', 'POST',
    ['client' =>
        [
            'company_name' => 'Infakt biuro rachunkowe',
            'nip' => '888-888-88-88'
        ]
    ]
);
  1. Get client by ID
/** @var Infakt $inFakt */
$inFakt = Yii::$app->infakt;
$response = $inFakt->call('clients/xxxxxx', 'GET');
  1. Add new invoice
/** @var Infakt $inFakt */
$inFakt = Yii::$app->infakt;
$response = $inFakt->call('invoices', 'POST',
    ['invoice' =>
        [
            'payment_method' => 'payu',
            'client_id' => 6567050,
            'services' => [
                [
                    'name' => 'Przykładowa Usługa',
                    'gross_price' => 6623,
                    'tax_symbol' => 23
                ]
            ]
        ]
    ]
);

Check inFakt API Documentation for all available options.