PHPackages                             tudorr89/fgo-php-api-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. tudorr89/fgo-php-api-sdk

ActiveLibrary[API Development](/categories/api)

tudorr89/fgo-php-api-sdk
========================

PHP client for the FGO Invoicing/Billing API v7.0 — create invoices, manage articles, query nomenclatures, and more. Ships with Laravel auto-discovery.

v1.0.4(2mo ago)017MITPHPPHP &gt;=8.1

Since May 16Pushed 2mo agoCompare

[ Source](https://github.com/tudorr89/fgo-php-api-sdk)[ Packagist](https://packagist.org/packages/tudorr89/fgo-php-api-sdk)[ Docs](https://github.com/tudorr89/fgo-php-api-sdk)[ RSS](/packages/tudorr89-fgo-php-api-sdk/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (6)Versions (6)Used By (0)

FGO API PHP Client
==================

[](#fgo-api-php-client)

[![PHP Version](https://camo.githubusercontent.com/04744bae0a61d2ffe29c26f07a9612eae20445fc6feaeb77b3af1f0e9be6447c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d3838393242462e737667)](https://php.net)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![Packagist](https://camo.githubusercontent.com/79c31c23b2f1aecd1f9a22475193ff708c6e10ae2a15079c26faed2a59acc499/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7061636b61676973742d7475646f7272383925324666676f2d2d7068702d2d6170692d2d73646b2d6f72616e67652e737667)](https://packagist.org/packages/tudorr89/fgo-php-api-sdk)

A fully-typed PHP client for the [FGO Invoicing/Billing API v7.0](https://api-testuat.fgo.ro/v1/testing.html).
Create and manage invoices, query nomenclatures, list articles, and more — with clean DTOs and Guzzle under the hood.

---

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- [Composer](https://getcomposer.org/)
- A [FGO](https://fgo.ro) account with an API user (Private Key)

---

Installation
------------

[](#installation)

```
composer require tudorr89/fgo-php-api-sdk
```

---

Quick Start
-----------

[](#quick-start)

```
use FgoApi\Client;
use FgoApi\Enums\Environment;
use FgoApi\Types\AddressClient;
use FgoApi\Types\InvoiceLine;

$client = new Client(
    codUnic:     'YOUR_CUI',
    privateKey:  'YOUR_PRIVATE_KEY',
    platformUrl: 'https://your-app.com',
    environment: Environment::Test,
);

// Create an invoice
$invoice = $client->invoices()->create(
    series:      'BV',
    currency:    'RON',
    invoiceType: 'Factura',
    clientData:  new AddressClient(
        name:    'Ionescu Popescu',
        country: 'RO',
        county:  'Bucuresti',
        type:    'PF',
    ),
    lines: [
        new InvoiceLine(
            name:      'Servicii Consultanta',
            quantity:   2,
            unit:      'ORE',
            vatRate:   19,
            unitPrice: 150.00,
        ),
    ],
);

echo "Invoice: {$invoice->series}{$invoice->number}\n";
echo "PDF: {$invoice->pdfLink}\n";
```

---

Laravel
-------

[](#laravel)

The package ships with auto-discovered service provider and facade — no manual registration needed.

### Configure

[](#configure)

```
php artisan vendor:publish --tag=fgo-config
```

Add to `.env`:

```
FGO_COD_UNIC=YOUR_CUI
FGO_PRIVATE_KEY=YOUR_PRIVATE_KEY
FGO_PLATFORM_URL=https://your-app.com
FGO_ENVIRONMENT=test          # or "production"
FGO_TIMEOUT=20
```

### Use it

[](#use-it)

```
use FgoApi\Laravel\Fgo;
use FgoApi\Types\AddressClient;
use FgoApi\Types\InvoiceLine;

$invoice = Fgo::invoices()->create(
    series:      'BV',
    currency:    'RON',
    invoiceType: 'Factura',
    clientData:  new AddressClient(name: 'Acme SRL'),
    lines:       [new InvoiceLine(name: 'Service', quantity: 1, unit: 'BUC', vatRate: 19, unitPrice: 100)],
);
```

Or via DI:

```
use FgoApi\Client;

public function __construct(private readonly Client $fgo) {}
```

### Multi-tenant / credentials from the database

[](#multi-tenant--credentials-from-the-database)

When each tenant (or merchant, or user) has their own FGO credentials, point the package at a **resolver** instead of reading from `.env`. Implement `FgoApi\Laravel\Contracts\CredentialsResolver`:

```
namespace App\Fgo;

use App\Models\Tenant;
use FgoApi\Laravel\Contracts\CredentialsResolver;

class TenantCredentialsResolver implements CredentialsResolver
{
    public function resolve(?string $key = null): array
    {
        $tenant = $key
            ? Tenant::findOrFail($key)
            : Tenant::current();

        return [
            'cod_unic'     => $tenant->fgo_cod_unic,
            'private_key'  => decrypt($tenant->fgo_private_key),
            'platform_url' => $tenant->platform_url,
            'environment'  => $tenant->fgo_environment, // "test" or "production"
        ];
    }
}
```

Register it in `config/fgo.php`:

```
'resolver' => \App\Fgo\TenantCredentialsResolver::class,
```

Then:

```
use FgoApi\Laravel\Fgo;

// Current tenant — resolver is called with null
Fgo::invoices()->create(...);

// Specific tenant — resolver is called with the key, result cached for the request
Fgo::for($tenantId)->invoices()->create(...);

// Ad-hoc credentials (e.g. testing, one-off jobs)
Fgo::make([
    'cod_unic'     => '...',
    'private_key'  => '...',
    'platform_url' => 'https://my-app.test',
    'environment'  => 'test',
])->invoices()->getStatus('001', 'BV');

// After rotating credentials
Fgo::forget($tenantId);
```

A closure is also accepted if you don't want a dedicated class:

```
// in a service provider
config(['fgo.resolver' => fn (?string $key) => Tenant::resolve($key)->fgoConfig()]);
```

---

Authentication
--------------

[](#authentication)

All requests are signed with an SHA-1 hash. The `Hash` helper provides the correct calculation for each endpoint category:

```
use FgoApi\Hash;

// Invoice creation — includes client name
Hash::forInvoiceCreate('CUI', 'PRIVATE_KEY', 'Client Name');

// Invoice operations (print, cancel, etc.) — includes invoice number
Hash::forInvoiceOperation('CUI', 'PRIVATE_KEY', '001');

// Articles, nomenclatures, warehouses — no extra data
Hash::forArticle('CUI', 'PRIVATE_KEY');
```

The `Client` handles hashing automatically — you never need to call these directly.

---

API Reference
-------------

[](#api-reference)

### Invoices

[](#invoices)

MethodEndpointDescription`invoices()->create(...)``POST /factura/emitere`Create and emit a new invoice`invoices()->print($num, $serie)``POST /factura/print`Generate PDF download link`invoices()->getStatus($num, $serie)``POST /factura/getstatus`Get invoice value and paid amount`invoices()->cancel($num, $serie)``POST /factura/anulare`Cancel (keeps in history)`invoices()->delete($num, $serie)``POST /factura/stergere`Permanently delete`invoices()->reverse($num, $serie)``POST /factura/stornare`Reverse / credit note`invoices()->addPayment(...)``POST /factura/incasare`Record a payment (Premium+)`invoices()->deletePayment($num, $serie)``POST /factura/stergereincasare`Delete a payment`invoices()->addTrackingNumber(...)``POST /factura/awb`Attach courier AWB`invoices()->listAssociated($num, $serie)``POST /factura/listfacturiasociate`List linked invoices (Enterprise)```
// Full create example
$result = $client->invoices()->create(
    series:          'BV',
    currency:        'RON',
    invoiceType:     'Factura',
    clientData:      new AddressClient(
        name:       'SC Example SRL',
        fiscalCode: 'RO12345678',
        email:      'contact@example.com',
        phone:      '0712345678',
        country:    'RO',
        county:     'Cluj',
        locality:   'Cluj-Napoca',
        address:    'Str. Principala, Nr. 10',
        type:       'PJ',
    ),
    lines: [
        new InvoiceLine(
            name:        'Dezvoltare Software',
            quantity:    1,
            unit:        'BUC',
            vatRate:     19,
            unitPrice:   5000.00,
            description: 'Modul facturare — luna aprilie',
        ),
    ],
    number:          null,
    issueDate:       date('Y-m-d'),
    dueDate:         null,
    checkDuplicate:  false,
    vatOnCollection: false,
);

// $result->number, $result->series, $result->pdfLink, $result->paymentLink, $result->stockInfo[]
```

### Nomenclatures

[](#nomenclatures)

MethodReturns`nomenclatures()->countries()`All countries`nomenclatures()->counties()`All counties`nomenclatures()->vatRates()`VAT rates`nomenclatures()->banks()`Banks`nomenclatures()->paymentTypes()`Payment types`nomenclatures()->invoiceTypes()`Invoice types`nomenclatures()->clientTypes()`Client types (PF/PJ)`nomenclatures()->localities('Bucuresti')`Localities by county code```
$types = $client->nomenclatures()->invoiceTypes();
// [ { name: "Normal", value: "Factura" }, { name: "Simplified", value: "FacturaSimplificata" } ]
```

### Articles

[](#articles)

MethodDescription`articles()->list($page, $perPage)`Paginated article list (Enterprise)`articles()->get($code)`Single article by account code`articles()->getList(array $codes)`Multiple articles, max 30 — **deprecated**`articles()->modifiedArticles($hoursBack, $hoursTo)`Articles modified in time window (Enterprise)```
$result = $client->articles()->list(page: 1, perPage: 50);
// $result->total, $result->articles[] — each Article has name, unitPrice, stock, barcode, etc.
```

### Warehouses

[](#warehouses)

```
$warehouses = $client->warehouses()->list();
// { code: "WH001", name: "Main Warehouse" }
```

---

Environments
------------

[](#environments)

```
use FgoApi\Enums\Environment;

// Test (UAT)
new Client(..., environment: Environment::Test);

// Production
new Client(..., environment: Environment::Production);

// Custom URL
new Client(..., environment: 'https://custom-fgo.example.com/v1');
```

---

Exception Handling
------------------

[](#exception-handling)

All exceptions extend `FgoApi\Exceptions\FgoApiException`:

ExceptionTrigger`FgoApiException`Generic API error (non-success response)`AuthenticationException`HTTP 401 — invalid credentials`RateLimitException`HTTP 429 — rate limit hit`NotFoundException`HTTP 404 — resource not found`HttpException`Other HTTP errors (includes status code + body)`ValidationException`Validation errors```
try {
    $invoice = $client->invoices()->create(...);
} catch (ValidationException $e) {
    // 400 / `Errors` map from API
    print_r($e->getErrors());
} catch (AuthenticationException $e) {
    // 401 / 403 — wrong CUI or private key
} catch (RateLimitException $e) {
    sleep(max(1, $e->getRetryAfter()));
    // ...retry
} catch (FgoApiException $e) {
    // All other API errors
}
```

---

Rate Limits
-----------

[](#rate-limits)

The API enforces per-endpoint rate limits. The client does **not** automatically retry — implement your own retry logic as needed:

EndpointLimitInvoice create / payment1 req/sec, 15s timeoutArticles1 req/5 secStandard endpointsNo explicit limit---

Development
-----------

[](#development)

```
git clone https://github.com/tudorr89/fgo-php-api-sdk
cd fgo-php-api-sdk
composer install

# Static analysis
composer analyse

# Run tests
composer test
```

---

License
-------

[](#license)

MIT. See [LICENSE](LICENSE).

Resources
---------

[](#resources)

- [FGO API Documentation](https://api-testuat.fgo.ro/v1/testing.html)
- [FGO Registration (Test)](https://testuat.fgo.ro/inregistrare)
- [FGO Registration (Production)](https://www.fgo.ro/inregistrare)

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance86

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

69d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3405514?v=4)[Tudor Rusu](/maintainers/tudorr89)[@tudorr89](https://github.com/tudorr89)

---

Top Contributors

[![tudorr89](https://avatars.githubusercontent.com/u/3405514?v=4)](https://github.com/tudorr89 "tudorr89 (5 commits)")

---

Tags

apilaravelbillinginvoicingAccountingE-InvoiceRomaniafgofacturare

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tudorr89-fgo-php-api-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/tudorr89-fgo-php-api-sdk/health.svg)](https://phpackages.com/packages/tudorr89-fgo-php-api-sdk)
```

###  Alternatives

[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

293.1k](/packages/eslazarev-wildberries-sdk)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.3M47](/packages/tencentcloud-tencentcloud-sdk-php)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)[mozex/anthropic-laravel

Laravel integration for the Anthropic API: facade, config publishing, install command, testing fakes, messages, streaming, tool use, thinking, and batches.

74331.3k1](/packages/mozex-anthropic-laravel)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

783.8k](/packages/scriptdevelop-whatsapp-manager)[bushlanov-dev/max-bot-api-client-php

Max Bot API Client library

486.3k](/packages/bushlanov-dev-max-bot-api-client-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
