PHP code example of shoket / php-shoket

1. Go to this page and download the library: Download shoket/php-shoket library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shoket / php-shoket example snippets


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

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


$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);
bash
composer