Search by

gosimple / tezga-laravel

IDabetic

Laravel integration for the Tezga Fiscal API: config, a Tezga facade, and a signed webhook route. A GoSimple product.

Package info

github.com/GoSimple-agency/tezga-laravel

pkg:composer/gosimple/tezga-laravel

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-10-14 23:01 UTC

This package is not auto-updated.

Last update: 2026-10-15 11:36:40 UTC


README

Tezga

tezga-laravel

CI PHP 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.

About

A product of GoSimple. See LICENSE and NOTICE.