taxora / sdk-php
Official PHP SDK for the Taxora VAT API (sandbox & production).
Installs: 615
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/taxora/sdk-php
Requires
- php: ^8.3 || ^8.4 || ^8.5
- php-http/discovery: ^1.19
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^2.0
- psr/simple-cache: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.88
- guzzlehttp/guzzle: ^7.9 || ^8.0
- http-interop/http-factory-guzzle: ^1.2
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.0
- vimeo/psalm: ^6.14
README
Taxora PHP SDK
Official PHP SDK for the Taxora VAT Validation API Validate EU VAT numbers, generate compliance certificates, and integrate VAT checks seamlessly into your systems â all with clean, modern PHP.
ð Overview
The Taxora SDK provides an elegant, PSR-compliant interface to the Taxora API, supporting:
- â Secure API-Key and Bearer Token authentication
- â Single & multiple VAT validation with AI-based company matching
- â VAT state history and search endpoints
- â Certificate generation (PDF) and bulk/list exports (ZIP or PDF)
- â Full test coverage & PSR-18 compatible HTTP client
- â PHP 8.3, 8.4, and (soon) 8.5 ready
ð The SDK itself is free to use, but a Taxora API subscription is required. You can obtain your
x-api-keyfrom your Taxora account developer settings.
ð§Ū Installation
Install via Composer:
composer require taxora/sdk-php
The package supports all PSR-18 clients (e.g. Guzzle, Symfony, Buzz) and PSR-17/PSR-7 factories.
Example dependencies for Guzzle:
composer require guzzlehttp/guzzle http-interop/http-factory-guzzle
âïļ Quick Start
use Taxora\Sdk\TaxoraClientFactory; use Taxora\Sdk\Enums\Environment; $client = TaxoraClientFactory::create( apiKey: 'YOUR_X_API_KEY', environment: Environment::SANDBOX // or PRODUCTION ); // 1ïļâĢ Authenticate $client->auth()->login('user@example.com', 'superSecret'); // 2ïļâĢ Validate a VAT number $vat = $client->vat()->validate('ATU12345678', 'Example GmbH'); echo $vat->state->value; // valid / invalid echo $vat->company_name; // Official company name echo $vat->score; // Overall confidence score (float) foreach ($vat->breakdown ?? [] as $step) { echo $step->stepName.' gave '.$step->scoreContribution.PHP_EOL; } // 3ïļâĢ Access company info $company = $client->company()->get(); // 4ïļâĢ Export certificates (returns a VatCertificateExport object) $export = $client->vat()->certificatesBulkExport('2024-01-01', '2024-12-31'); $pdfZip = $client->vat()->downloadBulkExport($export->exportId); file_put_contents('certificates.zip', $pdfZip);
vat()->validate() returns a VatResource object that includes the canonical VAT number, status, requested company name echo, and optional scoring data. The score reflects the overall confidence (higher is better), while breakdown provides an array of ScoreBreakdown objects describing every validation step, its score contribution, and any metadata (e.g. matched addresses or mismatched fields).
Need to plug in your own PSR-18 client or PSR-17 factories (e.g. to add logging or retries)? Call the constructor directly or pass them as optional overrides to the factory:
use GuzzleHttp\Client as GuzzleAdapter; use Http\Factory\Guzzle\RequestFactory; use Http\Factory\Guzzle\StreamFactory; use Taxora\Sdk\TaxoraClientFactory; $client = TaxoraClientFactory::create( apiKey: 'YOUR_X_API_KEY', http: new GuzzleAdapter(), requestFactory: new RequestFactory(), streamFactory: new StreamFactory() );
ð§Đ Architecture
The SDK follows clean separation of concerns:
TaxoraClient
âââ auth() â AuthEndpoint (login, refresh)
âââ company() â CompanyEndpoint (company info)
âââ vat() â VatEndpoint (validate, history, search, certificate)
Each endpoint handles:
- Request signing with
x-api-key - Bearer token refresh if expired or unauthorized
- PSR-7 response parsing into DTOs
ðĶ DTOs
| Class | Description |
|---|---|
VatResource |
Represents a single VAT validation result (normalized VAT UID, state, score, breakdown, company data) |
ScoreBreakdown |
Scoring fragment with validation step name, score contribution, and metadata context for the decision |
VatCollection |
Iterable list of VatResource objects |
Token |
Auth token with expiry & type |
Example:
$dto = $client->vat()->validate('ATU12345678'); print_r($dto->toArray());
ð Authentication Flow
-
Login
$client->auth()->login('email', 'password', device: 'my-server-01'); // Passing device is optional; omitted value falls back to a generated host-based identifier.
Need to authenticate with a technical
client_idinstead of an email?$client->auth()->loginWithClientId('client_abc123', 'client-secret', device: 'integration-box');
Advanced: you can still pass
loginIdentifier: LoginIdentifier::CLIENT_IDintologin()if you prefer an explicit enum instead of the helper.â Stores and returns a
TokenDTO (valid for ~3600 seconds). -
Auto-refresh The client automatically refreshes the token on
401responses. -
Manual refresh (optional)
$client->auth()->refresh();
-
Token storage By default, tokens are stored in memory. You can provide a PSR-16 cache adapter for persistence:
use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Psr16Cache; use Taxora\Sdk\Http\Psr16TokenStorage; $cache = new Psr16Cache(new FilesystemAdapter()); $storage = new Psr16TokenStorage($cache); $client = new TaxoraClient($http, $reqF, $strF, 'YOUR_KEY', $storage);
ðĪŠ Testing
Run the test suite locally:
composer test
CI runs on PHP 8.3, 8.4, and (soon) 8.5, verifying:
- PHPUnit 12
- Psalm static analysis
- Code style checks
ðïļ Environments
| Environment | Base URL |
|---|---|
| Sandbox | https://sandbox.taxora.io/v1 |
| Production | https://api.taxora.io/v1 |
Need sandbox sample data? Known VAT UIDs with deterministic responses live in tests/Fixtures/SandboxVatFixtures.php.
Switch easily via the constructor:
$client = new TaxoraClient(..., environment: Environment::PRODUCTION);
â ïļ Deprecations
So fresh there aren't even any deprecated features yet. Check back in a few months when we're on v47 and have made some regrettable decisions. ð
ðŠŠ License
Licensed under the MIT License ÂĐ 2025 theconcept technologies. The SDK is open-source, but API usage requires a valid Taxora subscription.
ðĪ Contributing
Contributions and pull requests are welcome!
- Follow PSR-12 coding style (
composer fix). - Run
composer testbefore submitting a PR. - Ensure new endpoints include DTOs + tests.
ðŽ Support
Need help or enterprise support? ð§ support@taxora.io ð https://taxora.io