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.1.1(10mo ago)0331[5 PRs](https://github.com/andreilungeanu/smartbill/pulls)MITPHPPHP ^8.2CI passing

Since Jun 16Pushed 4mo 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 1mo ago

READMEChangelog (3)Dependencies (10)Versions (8)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 and 12.

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_USERNAME=your-username
SMARTBILL_API_TOKEN=your-api-token

```

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\Support\Facades\Http;

// Manually create and configure the HTTP client
$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

37

—

LowBetter than 83% of packages

Maintenance67

Regular maintenance activity

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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 ~14 days

Total

3

Last Release

308d 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 (8 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

[spatie/laravel-query-builder

Easily build Eloquent queries from API requests

4.4k26.9M220](/packages/spatie-laravel-query-builder)[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[resend/resend-laravel

Resend for Laravel

1191.4M6](/packages/resend-resend-laravel)[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[joggapp/laravel-aws-sns

Laravel package for the SNS events by AWS

3171.8k](/packages/joggapp-laravel-aws-sns)

PHPackages © 2026

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