PHPackages                             andreilungeanu/smartbill - 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. andreilungeanu/smartbill

ActiveLibrary[API Development](/categories/api)

andreilungeanu/smartbill
========================

A Laravel package for the Smartbill API.

v1.3.0(2mo ago)0381[3 PRs](https://github.com/andreilungeanu/smartbill/pulls)MITPHPPHP ^8.2CI passing

Since Jun 16Pushed 1w agoCompare

[ Source](https://github.com/andreilungeanu/smartbill)[ Packagist](https://packagist.org/packages/andreilungeanu/smartbill)[ Docs](https://github.com/andreilungeanu/smartbill)[ GitHub Sponsors](https://github.com/andreilungeanu)[ RSS](/packages/andreilungeanu-smartbill/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (21)Versions (13)Used By (0)

Smartbill Laravel Package
=========================

[](#smartbill-laravel-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3becda1d80b15a80e4e5eae752057378278e43bb3ac0aa3dfbd73bf90fbde39e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e647265696c756e6765616e752f736d61727462696c6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/andreilungeanu/smartbill)[![Total Downloads](https://camo.githubusercontent.com/90b505d34f4b4d5217760d3c1219f2e17b40c956ad727114209148256af7401e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e647265696c756e6765616e752f736d61727462696c6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/andreilungeanu/smartbill)

A Laravel package for the Smartbill API, offering full compatibility with Laravel versions 11, 12, and 13.

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

[](#installation)

You can install the package via composer:

```
composer require andreilungeanu/smartbill
```

Configuration
-------------

[](#configuration)

You can publish the configuration file with:

```
php artisan vendor:publish --provider="AndreiLungeanu\Smartbill\SmartbillServiceProvider"
```

This will create a `config/smartbill.php` file in your application's config directory. You should add your Smartbill API credentials to your `.env` file:

```
SMARTBILL_API_USERNAME=your-username
SMARTBILL_API_TOKEN=your-api-token

# Optional — HTTP request timeout in seconds (default: 30)
SMARTBILL_TIMEOUT=30

```

Usage Examples
--------------

[](#usage-examples)

You can interact with the API in two primary ways:

#### 1. Using the Facade (recommended for Laravel)

[](#1-using-the-facade-recommended-for-laravel)

This is the most convenient method for use within a Laravel application.

```
use AndreiLungeanu\Smartbill\Facades\Smartbill;

$response = Smartbill::invoices()->create($invoiceData);
```

#### 2. Using the Service Container

[](#2-using-the-service-container)

This is useful for dependency injection within your own classes.

```
use AndreiLungeanu\Smartbill\Smartbill;

$smartbill = app(Smartbill::class);
$response = $smartbill->invoices()->create($invoiceData);
```

Both of these methods work seamlessly because Laravel's service container automatically handles the creation of the required HTTP client and injects it into the package.

#### 3. Manual Instantiation (Advanced)

[](#3-manual-instantiation-advanced)

Direct instantiation with `new Smartbill()` is no longer possible due to the new dependency injection requirement. If you need to use this package outside of a Laravel application or wish to manually construct the object, you must now provide a configured `Illuminate\Http\Client\PendingRequest` instance to its constructor.

```
use AndreiLungeanu\Smartbill\Smartbill;
use Illuminate\Http\Client\Factory;

// Manually create and configure the HTTP client
$http = new Factory();
$client = $http->withBasicAuth('your-username', 'your-api-token')
    ->baseUrl('https://ws.smartbill.ro/SBORO/api')
    ->acceptJson();

// Pass the configured client to the constructor
$smartbill = new Smartbill($client);
$response = $smartbill->invoices()->create($invoiceData);
```

### Example 1: Creating an Invoice

[](#example-1-creating-an-invoice)

This example shows how to create a new invoice and retrieve its number.

```
use AndreiLungeanu\Smartbill\Facades\Smartbill;

$invoiceData = [
    "companyVatCode" => "YOUR_COMPANY_VAT_CODE",
    "client" => [
      "name" => "UPBIT WEB DESIGN SRL",
      "vatCode" => "39521446",
      "isTaxPayer" => true,
      "address" => "str. Suhurlui, nr. 8",
      "city" => "Pechea",
      "county" => "Galati",
      "country" => "Romania",
      "email" => "contact@upbit.ro",
      "saveToDb" => false
    ],
    "issueDate" => now()->format('Y-m-d'),
    "seriesName" => "YOUR_INVOICE_SERIES",
    "isDraft" => false,
    "dueDate" => now()->addDays(14)->format('Y-m-d'),
    "deliveryDate" => now()->format('Y-m-d'),
    "products" => [
      [
        "name" => "Produs 1",
        "isDiscount" => false,
        "measuringUnitName" => "buc",
        "currency" => "RON",
        "quantity" => 1,
        "price" => 10,
        "saveToDb" => false,
        "isService" => false
      ]
    ]
];

// The create method returns an array with the API response
try {
   $response = Smartbill::invoices()->create($invoiceData);
   // You can now access the invoice number
   $invoiceNumber = $response['number']; // "0044"
} catch (\AndreiLungeanu\Smartbill\Exceptions\SmartbillApiException $e) {
   // Handle Smartbill API errors
   Log::error('Smartbill API error: ' . $e->getMessage());
   // Optionally, show a user-friendly message or handle as needed
}
```

#### Example API Response

[](#example-api-response)

A successful `create` call will return an array decoded from the following JSON structure:

```
{
    "errorText": "",
    "message": "",
    "number": "0044",
    "series": "SBINV",
    "url": ""
}
```

---

### Example 2: Downloading an Invoice PDF

[](#example-2-downloading-an-invoice-pdf)

This example shows how to download the PDF content of an existing invoice.

```
use AndreiLungeanu\Smartbill\Facades\Smartbill;
use Illuminate\Support\Facades\Storage;

$cif = 'YOUR_COMPANY_VAT_CODE';
$series = 'SBINV';
$number = '0044';

// The getPdf method returns the raw PDF content as a string on success,
// or an array with error details if not found or failed.
try {
    $pdfContent = Smartbill::invoices()->getPdf($cif, $series, $number);
    Storage::disk('local')->put("invoices/{$series}-{$number}.pdf", $pdfContent);
} catch (\AndreiLungeanu\Smartbill\Exceptions\SmartbillApiException $e) {
    Log::error('Smartbill PDF error: ' . $e->getMessage());
    // Optionally, show a user-friendly message or handle as needed
}
```

---

### And many more...

[](#and-many-more)

This is just a small sample of the available methods. For a complete list of all available endpoints and their parameters, please see the [full documentation](DOCUMENTATION.md).

Known Issues
------------

[](#known-issues)

When working with the Smartbill API, there are a few known issues to be aware of:

1. **Internal Server Errors on Invalid Request Data**: The API may return a `500 Internal Server Error` when the request payload contains invalid data, such as a typo in a required field name.

    For example, sending `nume` instead of `name` in the client object will trigger a `500` error:

    ```
    $invoiceData = [
        "companyVatCode" => "YOUR_COMPANY_VAT_CODE",
        "client" => [
          "nume" => "Test Client SRL", // Incorrect: should be "name"
          "vatCode" => "12345678",
          // ...
        ],
        // ...
    ];
    ```

    Ideally, the API should respond with a `400 Bad Request` status and a helpful error message detailing which field is incorrect. Instead, it returns a generic `500` error, which makes debugging difficult as it incorrectly suggests a server-side failure rather than a client-side mistake.

While this package attempts to mitigate these issues where possible, the fundamental problems lie with the API's implementation. We are awaiting fixes from the Smartbill provider to ensure more reliable and standards-compliant behavior.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [AndreiLungeanu](https://github.com/andreilungeanu)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance92

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.5% 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 ~76 days

Total

5

Last Release

75d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6858b95ca04a488da5ac7ddf7970b734ea42a4982a378532cd7c7ee23a5429ac?d=identicon)[andreilungeanu](/maintainers/andreilungeanu)

---

Top Contributors

[![andreilungeanu](https://avatars.githubusercontent.com/u/95976259?v=4)](https://github.com/andreilungeanu "andreilungeanu (22 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![oriceon](https://avatars.githubusercontent.com/u/358823?v=4)](https://github.com/oriceon "oriceon (1 commits)")

---

Tags

apiinvoicelaravelphpsmartbilllaravelsmartbillAndreiLungeanu

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/andreilungeanu-smartbill/health.svg)

```
[![Health](https://phpackages.com/badges/andreilungeanu-smartbill/health.svg)](https://phpackages.com/packages/andreilungeanu-smartbill)
```

###  Alternatives

[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.6k3](/packages/defstudio-telegraph)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1563.1k4](/packages/masterix21-laravel-licensing)

PHPackages © 2026

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