gawrys / counterparty-laravel
Laravel bridge for counterparty-verification: service provider, config, validation rules, queued verification job and facade.
Requires
- php: >=8.2
- gawrys/counterparty-core: ^0.1
- illuminate/contracts: ^11.0 || ^12.0
- illuminate/support: ^11.0 || ^12.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- gawrys/counterparty-ai: ^0.1
- larastan/larastan: ^3.0
- nyholm/psr7: ^1.8
- orchestra/testbench: ^9.0 || ^10.0
- php-http/mock-client: ^1.6
- phpstan/phpstan: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpunit/phpunit: ^11.0
Suggests
- gawrys/counterparty-ai: Enables AI-assisted advisory risk research (strategy=ai).
README
The Laravel bridge for the Counterparty Verification toolkit: auto-wired service provider, a facade, validation rules, a queued job and an event.
⚠️ A due-diligence aid, not a guarantee of AML compliance. Risk output is advisory.
Features
- Zero-config auto-discovery - PSR contracts mapped onto Laravel's HTTP client, cache and log; reference registries and checks registered for you.
- Facade -
Counterparty::verify()and Storage-styleCounterparty::extendRegistry(). - Validation rules -
ActiveVatPayer,NotSanctioned. - Async - queued
VerifyCounterpartyjob dispatching aCounterpartyFlaggedevent. - Selectable strategy & sanctions provider via published config; conditional AI wiring.
Installation
composer require gawrys/counterparty-laravel php artisan vendor:publish --tag=counterparty-config
Zero-config HTTP. The provider auto-discovers an installed PSR-18 client + PSR-17
factories - on a stock Laravel app this uses the bundled Guzzle (Guzzle 7 is a PSR-18
client), so you don't have to install or wire anything. To use a different client, just bind
Psr\Http\Client\ClientInterface (and the PSR-17 factories) in your app - your binding wins.
Usage
use Gawrys\Counterparty\Laravel\Facades\Counterparty; use Gawrys\Counterparty\Counterparty as Subject; $outcome = Counterparty::verify(new Subject('Acme', 'PL', nip: '1234567890')); Counterparty::extendRegistry('de', fn () => new GermanRegistryDriver(app(JsonHttpClient::class)));
Validation:
$request->validate([ 'nip' => ['required', new \Gawrys\Counterparty\Laravel\Rules\ActiveVatPayer()], 'name' => ['required', new \Gawrys\Counterparty\Laravel\Rules\NotSanctioned()], ]);
Async:
\Gawrys\Counterparty\Laravel\Jobs\VerifyCounterparty::dispatch($counterparty); // dispatches Events\CounterpartyFlagged when the outcome is adverse or needs review
Set COUNTERPARTY_STRATEGY=ai (and install gawrys/counterparty-ai + bind an
AiResearchProvider) to switch to advisory AI scoring - wiring is conditional on the
package being present.
Full guide: documentation.
Testing
composer check # php-cs-fixer + PHPStan max (larastan) + PHPUnit (orchestra/testbench)
Changelog
See CHANGELOG.md.
Contributing & Security
Pull requests welcome. Report security issues privately - see SECURITY.md.
Credits
License
The MIT License (MIT). See LICENSE.