A client to communicate with Exact from your Laravel application.
Install the composer package.
composer require justbetter/laravel-exact-client
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
.
By default, no middleware has been added to authorize with Exact. Update the middleware
in your configuration to add proper authentication and authorization.
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.
- Open the login page.
- Click on the login button in the section "Exact Online App Store"
- 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.
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.
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();
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.
To ensure the quality of this package, run the following command:
composer quality
This will execute three tasks:
- Makes sure all tests are passed
- Checks for any issues using static code analysis
- Checks if the code is correctly formatted
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.