johnstef/elorus-fuse-php
Composer 安装命令:
composer require johnstef/elorus-fuse-php
包简介
PHP SDK for the Elorus Fuse e-invoicing API
README 文档
README
A modern, typed PHP client for the Elorus Fuse Developer API (v1.0).
Elorus Fuse is a certified e-invoicing provider that lets businesses issue, send and archive electronic invoices, receipts and other commercial documents, with transmission to the Greek myDATA platform.
This SDK wraps the Elorus Fuse Developer API with strongly-typed request/response objects (DTOs), enums for myDATA code lists, and a pluggable HTTP layer.
Features
- 🧱 Typed DTOs for every request and response — no untyped arrays.
- 🔤 Enums for myDATA code lists (invoice types, payment methods, VAT exemptions, currencies, country codes, …).
- 🔌 Pluggable HTTP client — ships with a Guzzle adapter, or bring your own via
HttpClientInterface. - 🚨 Rich exceptions that expose field-level, integrity and myDATA validation errors.
- ✅ PHP 8.1+,
declare(strict_types=1), PHPStan level 6.
Requirements
- PHP 8.1 or higher
ext-json- An HTTP client. The bundled
GuzzleHttpClientadapter requiresguzzlehttp/guzzle(^7.0), or you can implement your own adapter.
Installation
composer require johnstef/elorus-fuse-php
If you plan to use the built-in Guzzle adapter, also install Guzzle:
composer require guzzlehttp/guzzle
Quick start
<?php require __DIR__ . '/vendor/autoload.php'; use ElorusFuse\ElorusFuse; $client = new ElorusFuse( apiKey: 'your-api-token', organizationVat: '999999999', ); // List invoices for the configured organization $result = $client->invoices()->list(); echo "Total: {$result->count}\n"; foreach ($result->results as $invoice) { echo "[{$invoice->uid}] {$invoice->invoiceType->value} #{$invoice->number} ({$invoice->issueDate})\n"; }
Configuration
The ElorusFuse constructor accepts:
| Parameter | Type | Required | Description |
|---|---|---|---|
apiKey |
string |
yes | Your API token. Sent as Authorization: Token <apiKey>. |
organizationVat |
string |
yes | Default organization VAT, sent as the X-Organization header for listings. |
httpClient |
?HttpClientInterface |
no | Custom HTTP client. Defaults to GuzzleHttpClient. |
baseUrl |
?string |
no | API base URL. Defaults to https://api.elorusfuse.gr. |
use ElorusFuse\ElorusFuse; // Point the client at the staging environment $client = new ElorusFuse( apiKey: 'your-api-token', organizationVat: '999999999', baseUrl: 'https://api.fuse-staging.gr', );
Usage
The client exposes four endpoint groups:
| Accessor | Covers |
|---|---|
$client->invoices() |
Create, list and email invoices; fetch QR codes. |
$client->providerSignatures() |
Request POS payment provider signatures. |
$client->paymentMethods() |
Submit payment methods for an already-issued invoice. |
$client->deliveryNotes() |
Cancel a delivery note. |
Create an invoice
use ElorusFuse\DTO\CreateInvoiceRequest; use ElorusFuse\DTO\InvoiceLine; use ElorusFuse\DTO\PaymentMethod; use ElorusFuse\DTO\Enum\CountryCode; use ElorusFuse\DTO\Enum\InvoiceType; use ElorusFuse\DTO\Enum\PaymentMethodType; $request = new CreateInvoiceRequest( issuerVatNumber: '999999999', invoiceType: InvoiceType::SaleInvoice, number: '4', issueDate: date('Y-m-d'), lines: [ new InvoiceLine( netValue: '100.00', vatCategory: 1, vatAmount: '24.00', description: 'Consulting services', ), ], totalNetValue: '100.00', totalVatAmount: '24.00', totalGrossValue: '124.00', series: 'MT', cpName: 'Test Customer', cpCountry: CountryCode::GR, cpVatNumber: '111111111', paymentMethods: [ new PaymentMethod(type: PaymentMethodType::Cash->value, amount: '124.00'), ], ); $invoice = $client->invoices()->create($request); echo "UID: {$invoice->uid}\n"; echo "Mark: {$invoice->mark}\n"; echo "Auth code: {$invoice->authenticationCode}\n"; echo "QR URL: {$invoice->qrUrl}\n";
List invoices with filters
use ElorusFuse\DTO\InvoiceListFilters; use ElorusFuse\DTO\Enum\InvoiceType; $filters = new InvoiceListFilters( periodFrom: '2026-01-01', periodTo: '2026-06-30', invoiceType: InvoiceType::SaleInvoice, page: 1, pageSize: 50, ); // The organization VAT defaults to the one set on the client; pass one to override. $result = $client->invoices()->list(filters: $filters); foreach ($result->results as $invoice) { echo "{$invoice->number}: {$invoice->totalGrossValue}\n"; }
You can also fetch the raw AADE/myDATA representation as a string:
$xmlOrJson = $client->invoices()->listAade(filters: $filters);
Email an invoice
use ElorusFuse\DTO\InvoiceEmailRequest; $response = $client->invoices()->email( $invoice->uid, new InvoiceEmailRequest( to: 'customer@example.com', cc: ['accounting@example.com'], ), ); echo "Sent to {$response->to}\n"; // Inspect the latest tracked emails for an invoice $emails = $client->invoices()->emailLatest($invoice->uid);
Fetch invoice QR codes
$qrCodes = $client->invoices()->qr($invoice->uid);
POS payment provider signature
use ElorusFuse\DTO\ProviderSignatureRequest; use ElorusFuse\DTO\Enum\InvoiceType; use ElorusFuse\DTO\Enum\PosProtocol; $signature = $client->providerSignatures()->create( new ProviderSignatureRequest( protocol: PosProtocol::VivaCloud, issuerVatNumber: '999999999', invoiceType: InvoiceType::RetailSalesReceipt, number: '101', issueDate: date('Y-m-d'), totalNetValue: '100.00', totalVatAmount: '24.00', totalGrossValue: '124.00', tidNsp: 'TID-12345', paymentAmount: '124.00', ), );
Submit payment methods
use ElorusFuse\DTO\PaymentMethodSubmissionRequest; use ElorusFuse\DTO\PaymentMethod; use ElorusFuse\DTO\Enum\PaymentMethodType; $submission = $client->paymentMethods()->update( new PaymentMethodSubmissionRequest( entityVatNumber: '999999999', mark: '400001234567890', paymentMethods: [ new PaymentMethod(type: PaymentMethodType::PosEpos->value, amount: '124.00'), ], ), );
Cancel a delivery note
use ElorusFuse\DTO\DeliveryNoteCancellationRequest; $cancellation = $client->deliveryNotes()->cancel( new DeliveryNoteCancellationRequest( entityVatNumber: '999999999', mark: '400001234567890', ), );
Error handling
All API errors throw an exception that extends ElorusFuse\Exception\ElorusFuseException:
| Exception | HTTP status | Meaning |
|---|---|---|
ValidationException |
400 |
Field, integrity or myDATA validation failure. |
AuthorizationException |
403 |
Authentication/permission failure. |
ElorusFuseException |
other 4xx/5xx |
Any other API error. |
ValidationException exposes structured details so you can react to the exact failure:
use ElorusFuse\Exception\AuthorizationException; use ElorusFuse\Exception\ValidationException; use ElorusFuse\Exception\ElorusFuseException; try { $invoice = $client->invoices()->create($request); } catch (ValidationException $e) { // Field-level errors, keyed by field name (line errors keyed by inner field) foreach ($e->getFieldErrors() as $field => $errors) { echo "{$field}: " . implode(', ', $errors) . "\n"; } // Cross-field / integrity errors foreach ($e->getIntegrityErrors() as $error) { echo "integrity: {$error}\n"; } // myDATA rejection errors foreach ($e->getMydataErrors() as $error) { echo "myDATA [{$error->code}]: {$error->message}\n"; } if ($e->getRejectedReason() !== null) { echo "rejected reason: {$e->getRejectedReason()}\n"; } } catch (AuthorizationException $e) { echo "Auth error: {$e->getMessage()}\n"; } catch (ElorusFuseException $e) { echo "API error ({$e->getCode()}): {$e->getMessage()}\n"; }
Enums
The SDK ships typed enums for the myDATA code lists, including:
InvoiceType— invoice/document types (e.g.InvoiceType::SaleInvoice=1.1).PaymentMethodType— payment methods (e.g.Cash,PosEpos,IrisDirectPayments).PosProtocol— POS connection protocols (e.g.VivaCloud,CommonTcp).VatExemptionCategory,SpecialInvoiceCategory,MovePurpose,TransmissionFailure.Currency,CountryCode.
Each case carries the underlying myDATA value, accessible via ->value.
Custom HTTP client
To integrate with your framework's HTTP layer, implement ElorusFuse\HttpClient\HttpClientInterface:
namespace ElorusFuse\HttpClient; interface HttpClientInterface { public function request( string $method, string $uri, array $headers = [], ?string $body = null, ): Response; }
Then pass your implementation to the client:
$client = new ElorusFuse( apiKey: 'your-api-token', organizationVat: '999999999', httpClient: new MyHttpClient(), );
Development
composer install # Run the test suite composer test # Static analysis (PHPStan level 6) composer analyse # Check / fix code style (PHP-CS-Fixer) composer cs composer cs-fix
License
Released under the MIT License.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-25