justbetter/laravel-exact-client

A client to interact with Exact

1.0.0 2025-05-06 13:10 UTC

This package is auto-updated.

Last update: 2025-05-06 13:11:47 UTC


README

Banner

Laravel Exact Client

Tests Coverage Analysis Total downloads

A client to communicate with Exact from your Laravel application.

Installation

Install the composer package.

composer require justbetter/laravel-exact-client

Setup

Publish the configuration of the package.

php artisan vendor:publish --provider="JustBetter\ExactClient\ServiceProvider" --tag=config

Run the migrations.

php artisan migrate

Add the following keys to your .env file:

EXACT_CLIENT_ID=
EXACT_CLIENT_SECRET=
EXACT_DIVISION=

Out of the box, the connection is called default.

Middleware

By default, no middleware has been added to authorize with Exact. Update the middleware in your configuration to add proper authentication and authorization.

Exact Apps

You have to create a new app in Exact Online. Make sure your account has the necessary permissions, otherwise you will be redirected back to the login page.

  1. Open the login page.
  2. Click on the login button in the section "Exact Online App Store"
  3. Register a new app.

Make sure the redirect URL is the callback URL of the application. This must be an HTTPS address.

https://localhost/exact/callback/default

Divisions in the configuration file must be unique across all connections.

Initiate Authentication

In order to initiate the authentication process with Exact, open the following link.

https://localhost/exact/authorize/default

After finishing the process, you can check your connection by requesting all available divisions.

php artisan exact:list-divisions default

Tokens are stored in the database.

Retaining Access

Making calls to Exact will make sure the tokens remain valid. The package automatically refreshes the tokens when required. If you are not regularly making calls to Exact, you should add the command below to your scheduler. Otherwise, the refresh token may expire and you'll have to authenticate with Exact again. A refresh token is valid for 30 days.

$schedule->command(\JustBetter\ExactClient\Commands\RefreshTokenCommand::class, [
    'connection' => 'default',
])->weekly();

Rate Limits

Exact is known for their strict rate limiting. It's generally recommended to distribute a load over a longer period of time. To prevent unnessecary failures further, this package includes a RateLimitMiddleware which is a job middleware to automatically release jobs back on the queue if a rate limit has been exceeded.

use JustBetter\ExactClient\Jobs\Middleware\RateLimitMiddleware;

public function middleware(): array
{
    return [
        RateLimitMiddleware::division('default'),
    ];
}

Rate limits are stored in the database.

Quality

To ensure the quality of this package, run the following command:

composer quality

This will execute three tasks:

  1. Makes sure all tests are passed
  2. Checks for any issues using static code analysis
  3. Checks if the code is correctly formatted

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

JustBetter logo