kfoobar / laravel-kivra
Laravel package for the Kivra Sender API
Requires
- php: ^8.0
- illuminate/http: >=9.0
- illuminate/support: >=9.0
Requires (Dev)
- orchestra/testbench: ^7.0|^8.0|^9.0|^10.0
- phpunit/phpunit: ^9.5|^10.0|^11.0
README
A lightweight Laravel package for interacting with the Kivra Sender API, supporting both live and sandbox environments.
Note: This package currently covers a limited subset of the Kivra API. Additional endpoints may be added in future releases.
Requirements
- PHP 8.0 or higher
- Laravel 9.0 or higher
Installation
Install the package via Composer:
composer require kfoobar/laravel-kivra
Publish the configuration file:
php artisan vendor:publish --tag=kivra-config
This will create a kivra.php file in your config directory.
Configuration
Add the following variables to your .env file:
KIVRA_CLIENT_ID= KIVRA_CLIENT_SECRET= KIVRA_TENANT_KEY= KIVRA_TEST_MODE=
KIVRA_TEST_MODE is optional and defaults to false. Set it to true to route all requests to the Kivra sandbox API.
Usage
Authenticate
Authentication uses the OAuth 2.0 client credentials flow. Call auth() before any other method:
use KFoobar\Kivra\Facades\Kivra; $kivra = Kivra::auth();
Find a Company
Look up a company by VAT number:
use KFoobar\Kivra\Facades\Kivra; $company = Kivra::auth()->company('556000-0000');
Returns an array with the company data, or an empty array if not found.
Contribution
Contributions are welcome! If you'd like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Make your changes and ensure tests pass.
- Submit a pull request with a detailed description of your changes.
License
This package is open-source and released under the MIT License. See LICENSE for more information.