Skip to content

Latest commit

 

History

History
83 lines (54 loc) · 2.98 KB

README.md

File metadata and controls

83 lines (54 loc) · 2.98 KB

Community of Trust PHP Integration Library

License CircleCI

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

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.