tezga-laravel maintained by gosimple
Description
Laravel integration for the Tezga Fiscal API: config, a Tezga facade, and a signed webhook route. A GoSimple product.
Author
Last update
2026/10/15 01:01
(dev-main)
License
Downloads
1
tezga-laravel
Laravel integration for the Tezga Fiscal API:
a configured client, a Tezga facade, and a signed webhook route — on top of the official
gosimple/tezga SDK.
Installation
composer require gosimple/tezga-laravel
Configure it from your .env:
TEZGA_API_KEY=tzg_your_key
TEZGA_PROVIDER=my-shop
TEZGA_WEBHOOK_SECRET=whsec_your_secret
Publish the config file if you want to tune it:
php artisan vendor:publish --tag=tezga-config
Issuing receipts
The Tezga facade is the SDK client, resolved from your config:
use GoSimple\TezgaLaravel\Facades\Tezga;
$doc = Tezga::issueReceipt([
'externalId' => "ORDER-{$order->id}",
'nacinPlacanja' => 'Kartica',
'stavke' => $order->items->map(fn ($i) => [
'naziv' => $i->name,
'kolicina' => $i->qty,
'cenaSaPdv' => $i->price,
])->all(),
'kupac' => ['naziv' => $order->buyer_name, 'email' => $order->buyer_email],
'posaljiMejl' => true,
]);
$order->update(['pfr' => $doc['fiskalni']['pfrBroj'] ?? null]);
Do this in a queued job so a slow fiscalization never blocks the checkout response.
Webhooks
When TEZGA_WEBHOOK_SECRET is set, the package registers POST /tezga/webhook (path
configurable). It verifies the X-Tezga-Signature against the raw body and fires an event;
an invalid signature is rejected with 401 before anything runs.
// app/Providers/EventServiceProvider.php
use GoSimple\TezgaLaravel\Events\TezgaWebhookReceived;
protected $listen = [
TezgaWebhookReceived::class => [RecordFiscalReceipt::class],
];
public function handle(TezgaWebhookReceived $e): void
{
// Deliveries are retried (1, 5, 15, 60, 360 min) — stay idempotent.
match ($e->event()) {
'racun.fiskalizovan' => /* ... */ null,
'refundacija.izvrsena', 'storno.izvrsen' => /* ... */ null,
default => null,
};
}
Point the Tezga webhook (Settings → Integrations) at https://your-app/tezga/webhook.