A convenient PHP package for the TokenEx API, (*1)
Installation
The fastest way to get up and running is to install via composer:, (*2)
$ composer require cliffom/tokenex
Usage
Tokenization
Initialize your tokenizer
require __DIR__ . '/vendor/autoload.php';
use Cliffom\Tokenex\Tokenizer;
$tokenizer = new Tokenizer($TOKENEX_API_BASE_URL, $TOKENEX_ID, $TOKENEX_API_KEY);
Create a token
// From a credit card number
$token = $tokenizer->token_from_ccnum(4242424242424242);
// From arbitrary data
$token = $tokenizer->tokenize("This is random data containing 3 numbers less than 10");
Validate a token
$tokenizer->validate_token($token); // true or false
Delete a token
$tokenizer->delete_token($token); // true or false
Errors and References
Each action call will return a reference ID that can be used to lookup a call in the TokenEx dashboard. Unsuccessful calls will also return an error describing the problem. Each can be accessed via:, (*3)
var_dump($tokenizer->error); // array, empty if no errors
var_dump($tokenizer->reference_number); // string
Development
Use the following docker-compose commands to install dependencies and run the specs:, (*4)
docker-compose run --rm tokenex composer install
docker-compose up
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/cliffom/tokenex-php., (*5)
License
All code is open source under the terms of the [MIT License](MIT License), (*6)