Skip to content

alphaolomi/php-shoket

Repository files navigation

Shoket Client for PHP

Latest Version on Packagist Tests Total Downloads

A Truly simple payments for your business. Shoket makes online payments more easier for all kind of business in Tanzania. From startups, small businesses to medium and large businesses.

Documentation

You can find the documentation for this package on Docs

Installation

Requires PHP 8.0 or higher

For Laravel users there is a dedicated intergration package laravel-shoket

You can install the package via composer:

composer require shoket/php-shoket

Usage

// Create a new instance of the client
$shoket = new Shoket(['apiSecret' => 'your-api-key']);

// Make a payment request
$response = $shoket->makePaymentRequest([
    "amount" => "5000",
    "customer_name" => "John Doe",
    "email" => "[email protected]",
    "number_used" => "255612345678",
    "channel" => "Tigo",
]);

// Print the response
print_r($response);

API Available

  • makePaymentRequest
  • verifyPayment

Make payment request API

Example

// Create a new instance of the client
$shoket = new Shoket(['apiSecret' => 'your-api-key']);

// Make a payment request
$response = $shoket->makePaymentRequest([
    "amount" => "5000",
    "customer_name" => "John Doe",
    "email" => "[email protected]",
    "number_used" => "255612345678",
    "channel" => "Tigo",
]);

// Print the response
var_dump($response);

verifyPayment API

Example

$shoketClient = new Shoket(['apiSecret' => 'your-api-key']);

// Get the payment reference from the a successful payment request
// Sample: adz49dS428b7kbDTdG4MN
$reference = 'your-reference-number'; 

$response  = $shoketClient->verifyPaymentRequest($reference,[
    "provider_name"=> "Vodacom",
    "provider_code"=> "MPESA"
]);

var_dump($response);

Testing

Uses Pest Testing Framework

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.