定制 netipar/szamlazzhu 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

netipar/szamlazzhu

Composer 安装命令:

composer require netipar/szamlazzhu

包简介

Modern Laravel package for the szamlazz.hu invoicing API

README 文档

README

laravel-szamlazzhu

Szamlazz.hu for Laravel

Latest Version on Packagist Tests Total Downloads

Modern Laravel package for the szamlazz.hu invoicing API. Generate invoices, receipts, proforma invoices, delivery notes, query invoice data, download PDFs, and more.

Based on the official szamlazz.hu PHP SDK v2.12.3, rebuilt for Laravel with modern PHP 8.3+ features.

Quick Example

use NETipar\Szamlazzhu\Client;
use NETipar\Szamlazzhu\Document\Invoice;
use NETipar\Szamlazzhu\Entity\Buyer;
use NETipar\Szamlazzhu\Enums\PaymentMethod;
use NETipar\Szamlazzhu\Item\InvoiceItem;

$client = app(Client::class);

$invoice = new Invoice();
$invoice->getHeader()->setPaymentMethod(PaymentMethod::BankTransfer);

$invoice->setBuyer(new Buyer(
    name: 'Customer Kft.',
    zipCode: '1234',
    city: 'Budapest',
    address: 'Main Street 1.',
));

$item = new InvoiceItem();
$item->setName('Product name')
    ->setNetUnitPrice(10000.0)
    ->setQuantity(2.0)
    ->setVat('27')
    ->setNetPrice(20000.0)
    ->setVatAmount(5400.0)
    ->setGrossAmount(25400.0);
$invoice->addItem($item);

$result = $client->generateInvoice($invoice);

$result->isSuccess();         // true
$result->getDocumentNumber(); // 'E-PREFIX-2026-001'
$result->getPdfFile();        // PDF binary string

Requirements

  • PHP 8.3+
  • Laravel 10, 11, 12, or 13
  • A szamlazz.hu account with API key

Installation

composer require netipar/szamlazzhu

Publish the config file:

php artisan vendor:publish --tag=szamlazzhu-config

Add your API key to .env:

SZAMLAZZHU_API_KEY=your-agent-key

Usage

Obtaining the Client

Always obtain the Client via dependency injection or the service container:

use NETipar\Szamlazzhu\Client;

// Dependency injection (preferred)
public function handle(Client $client): void
{
    $result = $client->generateInvoice($invoice);
}

// Or via service container
$client = app(Client::class);

Generate an Invoice

use NETipar\Szamlazzhu\Client;
use NETipar\Szamlazzhu\Document\Invoice;
use NETipar\Szamlazzhu\Entity\Buyer;
use NETipar\Szamlazzhu\Entity\Seller;
use NETipar\Szamlazzhu\Enums\Currency;
use NETipar\Szamlazzhu\Enums\Language;
use NETipar\Szamlazzhu\Enums\PaymentMethod;
use NETipar\Szamlazzhu\Item\InvoiceItem;

$invoice = new Invoice();

$header = $invoice->getHeader();
$header->setIssueDate(now()->format('Y-m-d'));
$header->setFulfillment(now()->format('Y-m-d'));
$header->setPaymentDue(now()->addDays(8)->format('Y-m-d'));
$header->setPaymentMethod(PaymentMethod::BankTransfer);
$header->setCurrency(Currency::HUF);
$header->setLanguage(Language::Hungarian);
$header->setComment('Invoice comment');

$invoice->setSeller(new Seller(
    bankName: 'OTP Bank',
    bankAccountNumber: '11111111-22222222-33333333',
));

$invoice->setBuyer(new Buyer(
    name: 'Customer Kft.',
    zipCode: '1234',
    city: 'Budapest',
    address: 'Main Street 1.',
    taxNumber: '12345678-1-42',
    email: 'customer@example.com',
));

$item = new InvoiceItem();
$item->setName('Product name')
    ->setNetUnitPrice(10000.0)
    ->setQuantity(2.0)
    ->setQuantityUnit('db')
    ->setVat('27')
    ->setNetPrice(20000.0)
    ->setVatAmount(5400.0)
    ->setGrossAmount(25400.0);
$invoice->addItem($item);

$result = $client->generateInvoice($invoice);

$result->isSuccess();         // bool
$result->getDocumentNumber(); // e.g. 'E-PREFIX-2026-001'
$result->getPdfFile();        // PDF binary string or null

Generate a Receipt

use NETipar\Szamlazzhu\Document\Receipt;
use NETipar\Szamlazzhu\Entity\Buyer;
use NETipar\Szamlazzhu\Enums\Currency;
use NETipar\Szamlazzhu\Enums\PaymentMethod;
use NETipar\Szamlazzhu\Item\ReceiptItem;

$receipt = new Receipt();
$receipt->getHeader()->setPrefix('NYGTA');
$receipt->getHeader()->setPaymentMethod(PaymentMethod::Cash);
$receipt->getHeader()->setCurrency(Currency::HUF);
$receipt->getHeader()->setOrderNumber('ORD-123'); // optional

$receipt->setBuyer(new Buyer(name: 'Customer Name'));

$item = new ReceiptItem();
$item->setName('Item name')
    ->setNetUnitPrice(10000.0)
    ->setQuantity(1.0)
    ->setQuantityUnit('db')
    ->setVat('27')
    ->setNetPrice(10000.0)
    ->setVatAmount(2700.0)
    ->setGrossAmount(12700.0);
$receipt->addItem($item);

$result = $client->generateReceipt($receipt);

Generate a Proforma Invoice

use NETipar\Szamlazzhu\Document\Proforma;

$proforma = new Proforma();
// Same structure as Invoice: getHeader(), setSeller(), setBuyer(), addItem()
$result = $client->generateProforma($proforma);

Generate a Delivery Note

use NETipar\Szamlazzhu\Document\DeliveryNote;

$note = new DeliveryNote();
// Same structure as Invoice: getHeader(), setSeller(), setBuyer(), addItem()
$result = $client->generateDeliveryNote($note);

Reverse (Storno) an Invoice

use NETipar\Szamlazzhu\Document\ReverseInvoice;

$invoice = new ReverseInvoice();
$invoice->getHeader()->setInvoiceNumber('E-PREFIX-2026-001');

$result = $client->generateReverseInvoice($invoice);

Reverse (Storno) a Receipt

use NETipar\Szamlazzhu\Document\ReverseReceipt;

$receipt = new ReverseReceipt();
$receipt->getHeader()->setReceiptNumber('NYGTA-2026-1');

$result = $client->generateReverseReceipt($receipt);

Record a Payment

use NETipar\Szamlazzhu\CreditNote\InvoiceCreditNote;
use NETipar\Szamlazzhu\Document\Invoice;

$invoice = new Invoice();
$invoice->getHeader()->setInvoiceNumber('E-PREFIX-2026-001');

$creditNote = new InvoiceCreditNote(
    date: now()->format('Y-m-d'),
    amount: 25400.0,
);
$invoice->addCreditNote($creditNote);

$result = $client->payInvoice($invoice);

Query Invoice Data

use NETipar\Szamlazzhu\Enums\LookupType;

// By invoice number (default)
$result = $client->getInvoiceData('E-PREFIX-2026-001');

// By order number
$result = $client->getInvoiceData('ORD-123', LookupType::OrderNumber);

// By external invoice id
$result = $client->getInvoiceData('EXT-77', LookupType::ExternalId);

if ($result->isSuccess()) {
    $data = $result->toArray();
}

Download Invoice PDF

use Illuminate\Support\Facades\Storage;
use NETipar\Szamlazzhu\Enums\LookupType;

$result = $client->getInvoicePdf('E-PREFIX-2026-001');

// By external invoice id
$result = $client->getInvoicePdf('EXT-77', LookupType::ExternalId);

$pdf = $result->toPdf();

if ($pdf) {
    Storage::put('invoices/E-PREFIX-2026-001.pdf', $pdf);
}

Query Receipt Data

use NETipar\Szamlazzhu\Enums\LookupType;

// By receipt number (default)
$result = $client->getReceiptData('NYGTA-2026-1');

// By order number
$result = $client->getReceiptData('ORD-123', LookupType::OrderNumber);

if ($result->isSuccess()) {
    $data = $result->toArray();
}

Download Receipt PDF

$result = $client->getReceiptPdf('NYGTA-2026-1');
$pdf = $result->toPdf();

if ($pdf) {
    Storage::put('receipts/NYGTA-2026-1.pdf', $pdf);
}

Query Taxpayer Data

// Pass the first 8 digits of the tax number
$result = $client->getTaxPayer('12345678');

if ($result->isSuccess()) {
    $data = $result->toArray();
}

Delete a Proforma Invoice

use NETipar\Szamlazzhu\Enums\LookupType;

// By proforma number (default)
$result = $client->deleteProforma('D-PREFIX-2026-001');

// By order number
$result = $client->deleteProforma('REND-2026-001', LookupType::OrderNumber);

Document Types

Class Purpose
Invoice Standard invoice
PrePaymentInvoice Pre-payment (advance) invoice
FinalInvoice Final invoice
CorrectiveInvoice Corrective invoice
ReverseInvoice Reverse (storno) invoice
Receipt Receipt
ReverseReceipt Reverse (storno) receipt
Proforma Proforma invoice
DeliveryNote Delivery note

All document classes live in NETipar\Szamlazzhu\Document\.

Enums

Always use enum cases instead of raw strings:

  • PaymentMethod - BankTransfer, Cash, CreditCard, Check, CashOnDelivery, PayPal, Szep, Otp, Compensation, Voucher, Barion, Other
  • Currency - HUF, EUR, USD, GBP, CHF, and 30+ ISO currencies
  • Language - Hungarian, English, German, Italian, Romanian, Slovak, Croatian, French, Spanish, Czech, Polish, Bulgarian, Dutch, Russian, Slovenian
  • VatRate - Percent27, Percent5, Percent0, TAM, AAM, EU, EUK, MAA, and more
  • LookupType - InvoiceNumber, OrderNumber, ExternalId
  • DocumentType - Invoice, ReverseInvoice, CorrectiveInvoice, PrepaymentInvoice, FinalInvoice, Proforma, DeliveryNote, Receipt, ReverseReceipt

Response Handling

Every Client method returns an ApiResponse:

$result->isSuccess();         // bool
$result->isFailed();          // bool
$result->getDocumentNumber(); // string|null
$result->getPdfFile();        // string|null (binary PDF)
$result->toPdf();             // string|null (alias)
$result->toArray();           // array|null
$result->toJson();            // string|null
$result->toXml();             // string|null
$result->getErrorMsg();       // string|null
$result->getErrorCode();      // int|null

Error Handling

use NETipar\Szamlazzhu\Exceptions\SzamlazzhuException;
use NETipar\Szamlazzhu\Exceptions\ConnectionException;
use NETipar\Szamlazzhu\Exceptions\ResponseException;
use NETipar\Szamlazzhu\Exceptions\ValidationException;
use NETipar\Szamlazzhu\Exceptions\XmlBuildException;

try {
    $result = $client->generateInvoice($invoice);
} catch (ConnectionException $e) {
    // Network / connection error
} catch (ResponseException $e) {
    // API response error
} catch (ValidationException $e) {
    // Input validation error
} catch (XmlBuildException $e) {
    // XML generation error
} catch (SzamlazzhuException $e) {
    // Base exception (catches all above)
}

Entity Properties

All entity, header, item, and document properties are public and can be read or written directly. Fluent setters are also available for chaining:

$buyer = new Buyer(
    name: 'Company Name',
    zipCode: '1234',
    city: 'Budapest',
    address: 'Street 1.',
);

// Direct property access
$buyer->taxNumber = '12345678-1-42';
$buyer->email = 'email@example.com';

// Or fluent setters (chainable)
$buyer->setPhoneNumber('+36201234567')->setComment('Note');

Configuration

Key .env variables:

SZAMLAZZHU_API_KEY=your-agent-key
SZAMLAZZHU_DOWNLOAD_PDF=true
SZAMLAZZHU_SAVE_PDF=true
SZAMLAZZHU_TIMEOUT=30
SZAMLAZZHU_SESSION_DRIVER=cache
SZAMLAZZHU_SESSION_DISK=local
SZAMLAZZHU_SESSION_TABLE=szamlazzhu_sessions
SZAMLAZZHU_LOG_CHANNEL=null

The session driver supports cache (default), file, database, and null (for testing).

For the database session driver, publish and run the migration first:

php artisan vendor:publish --tag=szamlazzhu-migrations
php artisan migrate

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.

netipar/szamlazzhu 适用场景与选型建议

netipar/szamlazzhu 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.36k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 02 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「invoice」 「laravel」 「hungary」 「szamlazz」 「számlázás」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 netipar/szamlazzhu 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 netipar/szamlazzhu 我们能提供哪些服务?
定制开发 / 二次开发

基于 netipar/szamlazzhu 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4.36k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-10