PHP code example of argist / laravel-invoice-webhook

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

    

argist / laravel-invoice-webhook example snippets


use Argist\InvoiceWebhook\Services\InvoiceApiService;

$invoiceData = [
    'bill_date' => '03/01/2026',
    'bill_time' => '14:30:00',
    'payment_status' => 1,
    'description' => 'Ürün satışı',
    'amount' => 1000,
    'total_tax' => 200,
    'total_amount' => 1200,
    'currency_id' => 1,
    'customer' => [
        'name' => 'Müşteri Adı',
        'email' => '[email protected]',
        'adress' => 'Adres Bilgisi',
        'tax_office' => 'Vergi Müdürlüğü',
        'tax_number' => '12345678901',
    ],
    'rows' => [
        [
            'title' => 'Ürün Adı',
            'quantity' => 2,
            'amount' => 500,
            'tax_rate' => 20,
            'currency_id' => 1,
            'row_sale_type' => '1',
            'product_id' => null,
            'service_id' => null,
            'quantity_unit_id' => 1,
            'tax_amount' => 200,
            'price_excluding_tax' => 1000,
            'total_amount' => 1200,
            'discount_amount' => 0,
            'discount_rate' => 0,
            'description' => 'Ürün açıklaması',
        ]
    ],
];

$result = InvoiceApiService::sendInvoice($invoiceData);

if ($result['success']) {
    // Fatura başarıyla gönderildi
    $invoiceId = $result['data']['id'] ?? null;
} else {
    // Hata oluştu
    $errorMessage = $result['message'];
    $errors = $result['errors'] ?? [];
}

use Argist\InvoiceWebhook\Services\JwtTokenService;

$tokenService = new JwtTokenService();

// Token al (cache'den ya da API'den)
$token = $tokenService->getToken();

// Cache'i temizle
$tokenService->clearCache();

// Fatura gönder
InvoiceApiService::sendInvoice(array $invoiceData): array

[
    'success' => bool,
    'status' => int (HTTP status code),
    'message' => string,
    'errors' => array (validation errors if any)
]
bash
php artisan vendor:publish --provider="Argist\InvoiceWebhook\Providers\InvoiceWebhookServiceProvider" --tag=argist-config