PHPackages                             rpsimao/invoicexpress-api - 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. rpsimao/invoicexpress-api

ActiveLibrary[API Development](/categories/api)

rpsimao/invoicexpress-api
=========================

Laravel Package to interact with InvoiceXpress API

0.5.8(6y ago)21394MITPHPPHP ^7.1

Since Jul 24Pushed 6y ago1 watchersCompare

[ Source](https://github.com/rpsimao/invoicexpress-api)[ Packagist](https://packagist.org/packages/rpsimao/invoicexpress-api)[ Docs](https://github.com/rpsimao/invoicexpress-api)[ RSS](/packages/rpsimao-invoicexpress-api/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (8)Versions (43)Used By (0)

![license](https://camo.githubusercontent.com/ba246b967b61e33bca190d196cf5ae3fdfba8cb64ae31444054f64bc3a5d9faa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f727073696d616f2f696e766f6963657870726573732d6170692e737667)![GitHub release](https://camo.githubusercontent.com/52a22a08a578d2ac57113c733725f340b3b967eacceea94542c5b32f2dc960a1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f727073696d616f2f696e766f6963657870726573732d6170692e737667)![Packagist release](https://camo.githubusercontent.com/be1ae8024ca3af539e50b5b35ceb5f1d9f98667ce2ac58fa28de1a894efd74c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f727073696d616f2f696e766f6963657870726573732d6170692e737667)

Laravel InvoiceXpress API
=========================

[](#laravel-invoicexpress-api)

Laravel package to interact with InvoiceXpress API

**Tested with Laravel 5.5.**\*

Table of Contents
-----------------

[](#table-of-contents)

- [1 - Installation](#1---installation)
    - [1.1 - Publish configuration](#11---publish-configuration)
    - [1.2 - Migrations](#12---migrations)
- [2 - Configuration](#2---configuration)
- [3 - Usage](#3---usage)
    - [3.1 - Eloquent Model](#31---eloquent-model)
    - [3.1.1 - One-to-One relationship with Laravel::Auth()](#311---one-to-one-relationship-with-laravel--auth--)
    - [3.2 - Interact with the API](#32---interact-with-the-api)
- [4 - Tests](#4---tests)
- [5 - Messages](#5---messages)
    - [5.1 - Error messages](#51---error-messages)
    - [5.2 - Success Messages](#52---success-messages)

1 - Installation
----------------

[](#1---installation)

Via Composer

```
$ composer require rpsimao/invoicexpress-api
```

In your config/app.php, register Providers and the Facade (Not needed for Laravel 5.5 upwards)

```
'providers' => [
....

rpsimao\InvoiceXpressAPI\InvoiceXpressAPIServiceProvider::class,

.....

'aliases' => [

.....

'InvoiceXpressClients' =>  rpsimao\InvoiceXpressAPI\InvoiceXpressAPIFacade::class,

.....
```

### 1.1 - Publish configuration

[](#11---publish-configuration)

```
$ php artisan vendor:publish --tag=ivxapi-config
```

In the configuration file, all the API endpoints are accessible, so for example you need to generate an invoice PDF:

```
config(invoicexpress.enpoints.invoice.generate_pdf);
```

All endpoints are generic like: `'api/pdf/{invoice-id}.xml'`, so there is a helper function for replacing the generic endpoint with the real value:

```
endpoint_replace(['the-real-value'], config(invoicexpress.enpoints.invoice.generate_pdf));
```

The first argument MUST be an array, and the **number of the itens to replace, must match the items to be replaced in the endpoint**. If not an exception is raised, and a fatal error is thrown.

### 1.2 - Migrations

[](#12---migrations)

```
$ php artisan vendor:publish --tag=ivxapi-migrations
$ php artisan migrate
```

2 - Configuration
-----------------

[](#2---configuration)

Add to your .env file your API Key and Account name

```

INVOICEXPRESS_API_KEY=
INVOICEXPRESS_ACCOUNT_NAME=

```

These will be read by the config file:

```
....

'api_key'      => env('INVOICEXPRESS_API_KEY'),
'account_name' => env('INVOICEXPRESS_ACCOUNT_NAME'),

....
```

> If you do not want to put your API key in the .env file, or prefer to get it on every request, you can call the `getAPIKey()` method. This way you can change the API key in your account frequently and not need to update the app.
>
> In the config file `invoicexpress`, there are 2 empty fields `['username', 'password']` so you can put the username/password there, if you want.

```
$client = new InvoiceXpressAPI();
$api_key = $client->getAPIKey('my-username', 'my-password');
....
//later in the query
....
$client->setQuery(['api_key' => $api_key]);
....
```

3 - Usage
---------

[](#3---usage)

> **Check the documentation for the params of the actions.**
>
> See:  https://invoicexpress.com/api/overview

**There are 2 Classes for working with the API:**

### 3.1 - Eloquent Model

[](#31---eloquent-model)

It has one custom function, for retrieve all your customers and put them into the DB.

You can make a cron job for retrieving them periodically.

```
//Accepts a flag (true or false[default])
InvoiceXpressClients::getAllClientsFromAPI(true);
```

If you pass the `true` flag, the function inserts the clients into the database. `False` or none, returns an array with all your clients.

If the client already exists, it updates the values.

### 3.1.1 - One-to-One relationship with Laravel::Auth()

[](#311---one-to-one-relationship-with-laravelauth)

If you wish to have a relationship between the InvoiceXpress and your app Users, do the following:

```
$ php artisan vendor:publish --tag=ivxapi-migrateauth
$ php artisan migrate
```

In your Users Model, add the following method:

```
class User extends Model
{
.......

//Get the InvoiceXpress Client record associated with the user.

public function invoicexpress()
{
	return $this->hasOne('InvoiceXpressClients');
}
```

You now have a one-to-one relationship. Now you only have to insert the user\_id in the InvoiceXpress table.

### 3.2 - Interact with the API

[](#32---interact-with-the-api)

```
use rpsimao\InvoiceXpressAPI\Service\InvoiceXpressAPI;

//Making a GET REQUEST

$client = new InvoiceXpressAPI();
$client->setMethod('GET');
$client->setUrl(config('invoicexpress.my_url'));
$client->setEndpoint(config('invoicexpress.endpoints.clients.list_all'));
$client->setQuery(['api_key' => config('invoicexpress.api_key')]);

$response = $client->talkToAPI();

.....

// Another GET Request to generate a PDF for an invoice

$client = new InvoiceXpressAPI();
$client->setMethod('get');
$client->setUrl(config('invoicexpress.my_url'));
$client->setEndpoint(
    endpoint_replace(['12759480'], config('invoicexpress.endpoints.invoices.generate_pdf'))
);
$client->setQuery([
        'api_key' => config('invoicexpress.api_key'),
        'invoice-id' => '12759480',
        'second_copy' => true
    ]);
$response = $client->talkToAPI();

//Making a POST REQUEST
// Creating a new Client

client = new InvoiceXpressAPI();
$client->setMethod('post');
$client->setUrl(config('invoicexpress.my_url'));
$client->setEndpoint( config('invoicexpress.endpoints.clients.create'));
$client->setQuery([
        'api_key' => config('invoicexpress.api_key'),
        'client' => [
        	'name' => 'My name',
        	'code' => 'My Client Code',
        	'email' => 'client@email.com'
        	//.... insert more values ....
        ]
    ]);
$response = $client->talkToAPI();

//Do whatever you need with the response

//Making a PUT REQUEST

$client = new InvoiceXpressAPI();
$client->setMethod('put');
$client->setUrl(config('invoicexpress.my_url'));
$client->setEndpoint(endpoint_replace(['123456789'], config('invoicexpress.endpoints.clients.update')));
$client->setQuery([
	'api_key' => config('invoicexpress.api_key'),
	'client-id' => '123456789',
	'client' => [
		'name' => 'My awesome Client',
		'code' => '123',
		'phone' =>  999888777
		//.... insert more values ....
		]
	]);
$response = $client->talkToAPI();

//Do whatever you need with the response
```

4 - Tests
---------

[](#4---tests)

Currently there are 4 tests available.

1. A GET Request to Retrieve all Clients
2. A PUT Request to Update Client Information
3. A GET Request for retrieve your API key
4. A GET Request for generate a Invoice PDF

For them to work, you have to fill with you own credentials | data:

```
class GetTest extends TestCase {

// Use your own credentials|data to run the tests

	protected $url          = '';
	protected $api_key      = '';
	protected $username     = '';
	protected $password     = '';
	protected $client_id    = '';
	protected $client_name  = '';
	protected $client_code  = '';
	protected $client_phone = '';
	protected $invoice      = '';

.......
```

Then you can run the tests:

```
$ cd your-laravel-project-folder
$ vendor/bin/phpunit vendor/rpsimao/invoicexpress-api
```

If all goes well, you should receive:

```
OK (4 tests, 4 assertions)
```

5 - Messages
------------

[](#5---messages)

By default all Error / Success messages are returned in XML format. If you wish to change to JSON, just add the `setMsgFormat()` method and pass the JSON flag:

```
.....
$client = new InvoiceXpressAPI();
$client->setMsgFormat('json');
......
```

### 5.1 - Error messages

[](#51---error-messages)

The` api_code` and `api_msg` are the real messages that the InvoiceXpress API returns, the others are just for debugging.

The debugging tags only appears if in the .env file: `APP_DEBUG=true`

This is how the Error Messages are returned:

#### XML

[](#xml)

```

	500
	Server error: `GET https://mycompany.app.invoicexpress.com/api/pdf/1234567.xml?api_key=11111abc2222def33333&amp;invoice-id=1234567` resulted in a `500 Internal Server Error` response: An error occured on the server. We have been notified.
	/Code/testapi/vendor/rpsimao/invoicexpress-api/src/Service/InvoiceXpressAPI.php
	408
	simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '&amp;lt;' not found

```

#### JSON

[](#json)

```
{
"api_code":"500",
"api_msg":"Server error: `GET https:\/\/mycompany.app.invoicexpress.com\/api\/pdf\/1234567.xml?api_key=11111abc2222def33333&invoice-id=1234567` resulted in a `500 Internal Server Error` response:\nAn error occured on the server. We have been notified.\n\n",
"file":"\/Code\/testapi\/vendor\/rpsimao\/invoicexpress-api\/src\/Service\/InvoiceXpressAPI.php",
"line":385,
"message":"simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '&lt;' not found"
}
```

### 5.2 - Success Messages

[](#52---success-messages)

This is how the Success Messages are returned:

#### XML

[](#xml-1)

```

	200
	OK
	https://invoicexpress-downloads.s3.amazonaws.com/store_00000_Factura-0000-a.pdf?AWSAccessKeyId=AAKKAAKKK&amp;Expires=1501762080&amp;Signature=vmePXICWhUBRLygwVO6y2Lx6x4M%3D&amp;response-content-disposition=attachment%3B%20filename%3DFactura-0000-a.pdf&amp;response-content-type=application%2Fpdf

```

#### JSON

[](#json-1)

```
{
  "response": {
    "api_code": "200",
    "api_msg": "OK",
    "api_values": { "pdfUrl": "https://invoicexpress-downloads.s3.amazonaws.com/store_00000_Factura-0000-a.pdf?AWSAccessKeyId= AAKKAAKKK&Expires=1501762080&Signature=vmePXICWhUBRLygwVO6y2Lx6x4M%3D&response-content-disposition=attachment%3B%20filename%3DFactura-0000-a.pdf&response-content-type=application%2Fpdf" }
  }
}
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Recently: every ~168 days

Total

42

Last Release

2538d ago

PHP version history (4 changes)0.0.1PHP &gt;=7.0.0

0.1.3PHP 7.0

0.1.4PHP ^7.0

0.5.7PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/b20557c62a96fca9a58d80b11dffbaf4e3debd77d9358c66ed06d413c1e884a7?d=identicon)[rpsimao](/maintainers/rpsimao)

---

Top Contributors

[![rpsimao](https://avatars.githubusercontent.com/u/205846?v=4)](https://github.com/rpsimao "rpsimao (6 commits)")

---

Tags

apilaravelinvoicexpressinvoicexpress-apirpsimao

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rpsimao-invoicexpress-api/health.svg)

```
[![Health](https://phpackages.com/badges/rpsimao-invoicexpress-api/health.svg)](https://phpackages.com/packages/rpsimao-invoicexpress-api)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[saloonphp/saloon

Build beautiful API integrations and SDKs with Saloon

2.4k9.6M468](/packages/saloonphp-saloon)[irazasyed/telegram-bot-sdk

The Unofficial Telegram Bot API PHP SDK

3.3k4.5M84](/packages/irazasyed-telegram-bot-sdk)[nickurt/laravel-postcodeapi

Universal PostcodeApi for Laravel 11.x/12.x/13.x

97221.2k](/packages/nickurt-laravel-postcodeapi)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)

PHPackages © 2026

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