trstd / cot-integration-library
A PHP integration library for connecting to Community of Trust platform.
Requires
- php: >=7.4
- firebase/php-jwt: ^6
- monolog/monolog: ^2
- phpfastcache/phpfastcache: ^8
- phpseclib/phpseclib: ^3
- symfony/http-client: ^5
Requires (Dev)
README
This library provides a comprehensive PHP interface for integrating with the Community of Trust (COT) platform, facilitating seamless interactions with its services.
Requirements
- PHP >= 7.4
- Composer for managing dependencies
Installation
To install the library, run the following command in your project directory:
composer require trstd/cot-integration-library
Usage
Here is a basic example of how to use the library:
On the backend side:
<?php require_once 'vendor/autoload.php'; use TRSTD\COT\Client; // Initialize the client $client = new Client( <TSID>, // Trusted Shops ID - e.g. 'X1234567890123456789012345678901' <CLIENT_ID>, // Client ID - e.g. 'cot-switch-X1234567890123456789012345678901' <CLIENT_SECRET>, // Client Secret - e.g. '1234567890123456789012345678901234567890123456789012345678901234' <AUTH_STORAGE_INSTANCE>, // It can be any storage option implementing AuthStorageInterface - e.g. new DatabaseAuthStorage() <ENV> // Environment (optional) - dev, qa, or prod, defaults to prod ); // Invoke handleCallback function to handle code coming from the authentication server $client->handleCallback(); // Get anonymous consumer data for the current user $client->getAnonymousConsumerData();
On the frontend side, place the following code in your HTML file where you want the widget to appear:
<trstd-switch tsId="X1234567890123456789012345678901"></trstd-switch> <script type="module" src="https://widgets.trustedshops.com/switch/switch.js"></script>
For more detailed examples, please refer to the examples/
directory.
Contributing
Contributions are welcome! Please refer to the CONTRIBUTING.md file for guidelines.
License
This library is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- firebase/php-jwt for JWT handling
- phpseclib/phpseclib for security features
- monolog/monolog for logging
- phpfastcache/phpfastcache for caching solutions
- symfony/http-client for HTTP client features
Versioning
This project adheres to Semantic Versioning. For the versions available, see the tags on this repository.
PHP Package Repository
This library is available on Packagist.