Skip to content

A PHP integration library for connecting to Community of Trust platform.

License

Notifications You must be signed in to change notification settings

trustedshops-public/cot-php-integration-library

Repository files navigation

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()
);

// 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.

About

A PHP integration library for connecting to Community of Trust platform.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages