1. Go to this page and download the library: Download kapasifulop/szamlazzphp 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/ */
kapasifulop / szamlazzphp example snippets
use Szamlazzphp\Facades\SzamlazzHU;
use Szamlazzphp\InvoiceBuilder;
use Szamlazzphp\Enum\PaymentMethod;
use Szamlazzphp\Enum\Currency;
use Szamlazzphp\Enum\Language;
// Számla lekérése
$invoice = SzamlazzHU::getInvoiceData('SZLA-12345');
// Számla kiállítása
$invoice = (new InvoiceBuilder($buyer))
->addItem($item)
->setPaymentMethod(PaymentMethod::BankTransfer)
->setCurrency(Currency::Ft)
->setLanguage(Language::Hungarian)
->build();
$result = SzamlazzHU::issueInvoice($invoice);
// Számla sztornózása
$result = SzamlazzHU::reverseInvoice('SZLA-12345', true, true);
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Szamlazzphp\Client\ClientInterface;
use Szamlazzphp\InvoiceBuilder;
use Szamlazzphp\Buyer;
use Szamlazzphp\Item;
use Szamlazzphp\Enum\Currency;
use Szamlazzphp\Enum\PaymentMethod;
use Szamlazzphp\Enum\Language;
class InvoiceController extends Controller
{
protected $client;
public function __construct(ClientInterface $client)
{
$this->client = $client;
}
public function issueInvoice(Request $request)
{
// Számla összeállítása
$invoice = (new InvoiceBuilder($buyer))
->addItem($item)
->setPaymentMethod(PaymentMethod::BankTransfer)
->setCurrency(Currency::Ft)
->setLanguage(Language::Hungarian)
->build();
// Számla kiállítása
$result = $this->client->issueInvoice($invoice);
return response()->json([
'success' => true,
'invoice_id' => $result['invoiceId']
]);
}
}
public function downloadInvoice($invoiceId)
{
// Kliens lekérése a Service Containerből
$client = app(ClientInterface::class);
// Számla adatok lekérdezése
$invoiceData = $client->getInvoiceData($invoiceId, null, true);
// További feldolgozás...
}
use Szamlazzphp\Client\SzamlaAgentClient;
use Szamlazzphp\Client\AuthBasedClient;
use Szamlazzphp\Invoice;
use Szamlazzphp\InvoiceBuilder;
use Szamlazzphp\Buyer;
use Szamlazzphp\Seller;
use Szamlazzphp\Item;
use Szamlazzphp\Enum\Currency;
use Szamlazzphp\Enum\PaymentMethod;
use Szamlazzphp\Enum\Language;
// API kulcs alapú kliens létrehozása
$client = new SzamlaAgentClient(
'your_token',
false, // eInvoice
true, // requestInvoiceDownload
1, // downloadedInvoiceCount
1, // responseVersion
0 // timeout
);
// Vagy felhasználónév-jelszó alapú kliens létrehozása
// Felhasználónév és jelszó páros csak akkor használható, ha nincs bekapcsolva a kétlépcsős azonosítás a Számlázz.hu fiókban!
// $client = new AuthBasedClient(
// 'your_username',
// 'your_password',
// false, // eInvoice
// true, // requestInvoiceDownload
// 1, // downloadedInvoiceCount
// 1, // responseVersion
// 0 // timeout
// );
// Vevő létrehozása
$buyer = new Buyer([
'name' => 'Vevő Neve',
'country' => 'Magyarország',
'zip' => '1234',
'city' => 'Budapest',
'address' => 'Példa utca 1.',
'email' => '[email protected]',
'taxNumber' => '12345678-1-42',
]);
// Eladó létrehozása (opcionális, ha az alapértelmezett számlázz.hu profilod megfelelő)
$seller = new Seller([
'bank' => 'OTP Bank',
'bankAccount' => '11111111-22222222-33333333',
]);
// Tétel létrehozása
$item = new Item([
'label' => 'Termék vagy szolgáltatás',
'quantity' => 1,
'unit' => 'db',
'vat' => 27, // ÁFA százalék
'netUnitPrice' => 10000, // nettó egységár
'comment' => 'Megjegyzés a tételhez',
]);
// Számla létrehozása Builder pattern segítségével (ajánlott)
$invoice = (new InvoiceBuilder($buyer))
->addItem($item)
->setPaymentMethod(PaymentMethod::BankTransfer)
->setCurrency(Currency::Ft)
->setLanguage(Language::Hungarian)
->setSeller($seller)
->setOrderNumber('ABC-123')
->setComment('Megjegyzés a számlához')
->build();
// Számla kiállítása
$result = $client->issueInvoice($invoice);
// Eredmény
echo "Számla azonosító: " . $result['invoiceId'] . PHP_EOL;
// Közvetlenül is létrehozható a számla (egyszerűbb esetekre)
$directInvoice = new Invoice(
$buyer,
[$item],
new DateTime(), // issueDate - kiállítás dátuma
new DateTime(), // fulfillmentDate - teljesítés dátuma
new DateTime(), // dueDate - fizetési határidő
PaymentMethod::BankTransfer,
Currency::Ft,
Language::Hungarian
);
$directInvoice->setSeller($seller);
$directInvoice->setOrderNumber('ABC-123');
// Több tétel hozzáadása
$builder = new InvoiceBuilder($buyer);
$builder->addItem($item1);
$builder->addItem($item2);
$builder->addItem($item3);
// Vagy tömb formában
$builder->setItems([$item1, $item2, $item3]);
// Dátumok beállítása
$builder->setIssueDate(new DateTime('2023-12-01'))
->setFulfillmentDate(new DateTime('2023-12-01'))
->setDueDate(new DateTime('2023-12-15'));
// Egyéb opcionális beállítások
$builder->setOrderNumber('ABC-123')
->setPaid(true)
->setProforma(false)
->setNoNavReport(false)
->setInvoiceIdPrefix('INVOICE')
->setComment('Megjegyzés a számlához')
->setLogoImage('path/to/logo.png');
// Pénznem és árfolyam beállítása
$builder->setCurrency(Currency::EUR)
->setExchangeRate(380.0)
->setExchangeBank('MNB');
// Véglegesítés és számla létrehozása
$invoice = $builder->build();
$client->issueInvoice($invoice);
// Vagy Laravelben
// $response = SzamlazzHU::issueInvoice($invoice);
$client->getInvoiceData('SZLA-123');
// vagy
$client->getInvoiceData(null, 'ABC-123');
// Vagy Laravelben
// $response = SzamlazzHU::getInvoiceData('SZLA-123');