1. Go to this page and download the library: Download banelsems/lara-sgmef-qr 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/ */
namespace App\Sgmef;
use Banelsems\LaraSgmefQr\Contracts\IfuResolverInterface;
class TenantIfuResolver implements IfuResolverInterface
{
public function resolve(?string $context = null): string
{
return tenant($context)->ifu;
}
}
use App\Sgmef\TenantIfuResolver;
use Banelsems\LaraSgmefQr\Contracts\IfuResolverInterface;
$this->app->bind(IfuResolverInterface::class, TenantIfuResolver::class);
use Banelsems\LaraSgmefQr\Jobs\CreateInvoiceJob;
use Banelsems\LaraSgmefQr\Jobs\ConfirmInvoiceJob;
use Banelsems\LaraSgmefQr\Jobs\SyncInvoiceJob;
use Banelsems\LaraSgmefQr\Jobs\CancelInvoiceJob;
use Banelsems\LaraSgmefQr\Jobs\CleanupExpiredPendingInvoicesJob;
// Payload = DTO->toArray() (array serialisable)
CreateInvoiceJob::dispatch($dto->toArray());
ConfirmInvoiceJob::dispatch($invoice->uid);
SyncInvoiceJob::dispatch($invoice->uid);
CancelInvoiceJob::dispatch($invoice->uid);
use Banelsems\LaraSgmefQr\Services\VerificationService;
$verification = app(VerificationService::class)->verify($confirmedInvoice);
if ($verification->valid) {
echo "Facture conforme. URL: " . $verification->verificationUrl;
} else {
foreach ($verification->issues as $issue) {
echo "Probleme: $issue\n";
}
}
$manager->cancelInvoiceByUid($invoice->uid); // PUT /cancel (standard)
$manager->cancelInvoiceByPost($invoice->uid); // POST /invoice/cancel (alternative)
use Banelsems\LaraSgmefQr\Events\SgmefAuthenticationAlert;
Event::listen(SgmefAuthenticationAlert::class, function ($event) {
// $event->httpStatus, $event->endpoint, $event->timestamp
Log::warning("Authentification DGI echouee", (array) $event);
});
use Banelsems\LaraSgmefQr\Services\TaxCalculatorService;
use Banelsems\LaraSgmefQr\Services\QrCodeService;
use Banelsems\LaraSgmefQr\Services\StatExportService;
$taxes = app(TaxCalculatorService::class)->calculateInvoice($data->items);
$verificationUrl = app(QrCodeService::class)->verificationUrl($confirmedInvoice);
$csvPath = app(StatExportService::class)->exportCsv(now()->startOfMonth(), now()->endOfMonth());
use Banelsems\LaraSgmefQr\Enums\InvoiceStatusEnum;
InvoiceStatusEnum::PENDING;
InvoiceStatusEnum::CONFIRMED;
InvoiceStatusEnum::CANCELLED;
InvoiceStatusEnum::EXPIRED;
InvoiceStatusEnum::ERROR;