PHP code example of gosimple / tezga-laravel

1. Go to this page and download the library: Download gosimple/tezga-laravel 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/ */

    

gosimple / tezga-laravel example snippets


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]);

// 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,
    };
}
bash
php artisan vendor:publish --tag=tezga-config