clapp/szamlazzhuclient

非官方 Számlázz.hu PHP 客户端。

v1.0.0-beta3 2017-10-22 19:25 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:20:07 UTC


README

非官方 Számlázz.hu PHP 客户端。试验性版本,不推荐在生产环境中使用。使用需自行负责。

安装

composer require clapp/szamlazzhuclient:1.*@beta

简单示例

$invoice = new Clapp\SzamlazzhuClient\Invoice();

$invoice->customerName = "Foo Bar";
$invoice->customerBillingPostcode = "1234";
$invoice->customerBillingCity = "Budapest";
$invoice->customerBillingAddress = "Foo utca 1.";

$invoice->merchantBankName = "FooBank";
$invoice->merchantBankAccountNumber = "12345678-12345678-12345678";

$invoice->items = [
    [
        'name' => 'Minta Termék',
        'quantity' => 2,
        'quantityUnit' => 'db',
        'netUnitPrice' => 100,
        'vatRate' => '25',
        'netValue' => 200,
        'vatValue' => 50,
        'grossValue' => 250,
    ],
    [
        'name' => 'Minta Termék 2',
        'quantity' => 1,
        'quantityUnit' => 'db',
        'netUnitPrice' => 100,
        'vatRate' => '25',
        'netValue' => 100,
        'vatValue' => 25,
        'grossValue' => 125,
    ],
];

$invoice->paymentMethod = 'utánvétel';
$invoice->currency = 'HUF';
$invoice->language = 'hu';

$invoice->signatureDate = '2016-01-02';
$invoice->settlementDate = '05/10/2015';
$invoice->dueDate = '2016-01-02';

try {
    /**
     * számla mezőinek ellenőrzése
     */
    $invoice->validate();
}catch(Illuminate\Validation\ValidationException $e){
    /**
     * hibás vagy hiányzó mezők
     */
    // var_dump( $e->validator->getMessages() );
}

$client = new Clapp\SzamlazzhuClient\SzamlazzhuClient();
$client->username = /* Számlázz.hu felhasználónév */;
$client->password = /* Számlázz.hu jelszó */;

try {
    $pdfContents = $client->generateInvoicePdf($invoice);
}catch(Clapp\SzamlazzhuClient\SzamlazzhuApiException $e){
    // var_dump( $e->getCode(), $e->getMessage() ); //API-ból származó hibakód és hibaüzenet
}
file_put_contents("szamlam.pdf", $pdfContents);

更多示例和使用说明

Github wiki中

文档

Github wiki中