Search by

trustcomponent / trustcomponent-php

trustcomponent

Official TrustComponent SDK for PHP: TrustCaptcha, TrustAnalytics, TrustMonitoring, Trust VAT Checker and the platform API.

Package info

github.com/trustcomponent/trustcomponent-php

Homepage

pkg:composer/trustcomponent/trustcomponent-php

Statistics

Installs: 12

Dependents: 0

Suggesters: 0

Stars: 0

v0.0.1-beta.5 2026-11-29 22:07 UTC

This package is auto-updated.

Last update: 2026-11-29 22:07:39 UTC


README

The official SDK for the TrustComponent API: TrustCaptcha, TrustAnalytics, TrustMonitoring, Trust VAT Checker and the platform API, in one package. Developed and hosted in the EU.

Requires PHP 8.1 or newer.

Install

composer require trustcomponent/trustcomponent-php

Check a TrustCaptcha result

The widget writes a verification token into your form. One call turns it into the result:

$tc = new TrustComponent\TrustComponent('ak_…');
$result = $tc->captcha()->getVerificationResult($_POST['tc-verification-token']);
if ($result->getIsVerificationPassed()) { /* … */ }

Create the API key (ak_…) in the dashboard under the project's API keys, or under the agency's API keys to reach its client projects. The key decides which projects and modules the client can use.

Every module

The client is module → resource → operation, with the same names in every language:

$project = $tc->platform()->projects()->getProjects()->getContent()[0];
$tc->analytics()->websites()->getWebsites($project->getId());
$tc->taxValidation()->validations()->createValidation($project->getId(), new TaxValidationValidationCreateParams(['countryCode' => 'DE', 'rawValue' => 'DE811569869']));
$tc->monitoring()->monitors()->pingHeartbeat($monitorId);
$tc->platform()->events()->getEventsOfProject($project->getId());

The full reference of every operation is at https://docs.trustcomponent.com.

Configuration

$tc = TrustComponent\TrustComponent::builder('ak_…')
    ->timeout(5)->maxRetries(1)->integration('my-plugin/1.0')
    ->build();

Options: host, connectTimeout, timeout, proxy, maxRetries, deprecationWarnings, integration, logger (PSR-3), handler (Guzzle).

The SDK retries only what the API reserves for retries: 429 with Retry-After, 502, 503, 504 and a lost connection (2 retries by default). When the API marks an operation as deprecated, it logs one warning per operation.

Every write (POST, PUT, PATCH, DELETE) carries an Idempotency-Key, a new one per call and the same one on each of its retries, so a retry after a lost answer never creates or deletes twice; a repeated answer carries Idempotent-Replayed: true. Pass your own key to make a call idempotent beyond one process, e.g. with your order number: TrustComponent::withIdempotencyKey('order-4711', fn () => $tc->taxValidation()->validations()->createValidation($projectId, $params)). Every request names the SDK in User-Agent and TrustComponent-Sdk, together with the integration you set.

Errors

Every error is a TrustComponent\Exception\TrustComponentException carrying the HTTP status and the stable code of the API: InvalidRequestException, AuthenticationException, PermissionException, PaymentRequiredException, LockedException, NotFoundException, ConflictException, GoneException, RateLimitException, ServerException, ConnectionException, OperationRetiredException, VerificationTokenInvalidException.

try {
    $tc->captcha()->getVerificationResult($token);
} catch (TrustComponent\Exception\NotFoundException $e) {
    // $e->getCode() is the HTTP status, $e->errorCode the stable reason of the API
}

OperationRetired means the operation was switched off after its sunset: update the SDK.

Support

The GitHub repository of this SDK is a read-only mirror of the released source, so pull requests and issues are not processed there. For questions and bug reports, write to mail@trustcomponent.com or contact support through https://www.trustcomponent.com.

License

MIT