Cellulant for PHP is a PHP client for the Tingg API a product of Cellulant.
The package is centered around Custom Checkout APIs provided by Tingg. It provides the following features:
- Checkout Request
- Charge Request
- Combined Checkout and Charge Request
- Acknowledgement Request
- Query Status
- Refund Request
- OTP Request and Validation
- PHP >= 8.0
- PHP
cURL
extension - Composer Package Manager
- Cellulant API Credentials, obtain them from Tingg Dev Portal
Preferable way to install is with Composer.
You can install the package via Composer:
composer require alphaolomi/php-cellulant
use Alphaolomi\CellulantService;
$cellulant = new CellulantService([
'clientId' => 'your clientId',
'clientSecret' => 'your clientSecret',
'apiKey' => 'your api key',
'serviceCode' => 'your service code',
'callbackUrl' => 'your callback url',
'env' => 'sandbox', // or 'production' // default is sandbox
]);
// Authentication
// Get the access token
$authRes = $cellulant->authenticate();
// $authRes is an array with the following keys
// [
// "token_type" => "bearer",
// "expires_in" => 3600,
// "access_token" => "WU3My1AHOcKsnxj3n",
// "refresh_token" => "GSWtHRnJrMHBzdEFPbjhNS0FjODIwMTU1NVlTb3c9PQ=="
// ]
// Checkout Request
$checkoutRes = $cellulant->checkoutRequest([
// ... Tingg Checkout Request Payload
]);
// Charge Request
$chargeRes = $cellulant->chargeRequest([
// ... Tingg Charge Request Payload
]);
// Query Status
$queryRes = $cellulant->queryStatus([
// ... Tingg Checkout Status Payload
]);
// Acknowledgement Request
$ackRes = $cellulant->acknowledgementRequest([
// ... Tingg Acknowledgement Payload
]);
// Refund Request
$refundRes = $cellulant->refundRequest([
// ... Tingg Refund Payload
]);
Refer to Features Test Cases for more usage examples.
Refer to Tingg API documentation for the required parameters reference for each method.
-
Calling
authenticate()
is not automatic, you have to call it manually before making any request. -
Calling
authenticate()
will keep the accessToken in memory for subsequent requests. -
Calling
authenticate()
only supports theclient_credentials
grant type. And will return an array with the following keys:token_type
,expires_in
,access_token
,refresh_token
. -
Error handling is not yet implemented, so you have to handle errors manually.
-
Methods accept an array of parameters, which are then converted to JSON before making the request. Refer to Tingg API documentation for the required parameters.
-
Methods array parameters are NOT validated, so you have to make sure you pass the correct parameters. With exception of
construct()
method which validates the required parameters. -
Method names are the same as the Tingg API endpoints.
-
The package uses Guzzle to make HTTP requests. Version ^7.0 is used.
-
Function Return Types are not implemented yet, so you have to manually cast the return values to the expected type.
Tests are written with Pest. To run the tests:
composer test
Do you like this project? Support it by Star this repository ⭐️ and follow me on Twitter for more updates 👍.
Please see CHANGELOG for more information on what has changed recently.
This project follows RomVer.
Please see CONTRIBUTING for details.
If you discover a security vulnerability within Laravel, please send an e-mail to Alpha Olomi via alphaolomi@gmail.com. All security vulnerabilities will be promptly addressed.
If you are having issues with this package, feel free to contact me on Twitter.
The MIT License (MIT). Please see License File for more information.