PHP code example of codelords / ssentezo-wallet

1. Go to this page and download the library: Download codelords/ssentezo-wallet 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/ */

    

codelords / ssentezo-wallet example snippets



use Codelords\SsentezoWallet;

$username = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$password = "zzzzzzzzzzzzzzzzzzzzzzzzzzzz";
$wallet = new SentezoWallet($username, $password);


/**
 * Environment
 * You can choose which environment you are using your wallet.
 * There are two possibilites production and sandbox
 * For testing purposes always use sandbox to avoid making errors that may result int real
 * money losses.
 */
$wallet->setEnvironment("sandbox");


/**
 * Currency
 * You can also select a currency you want to use
 *
 */
$wallet->setCurrency("UGX");


use Codelords\SsentezoWallet;

$wallet = new SsentezoWallet($username, $password);
$username =  "xxxxxxxxxxxxxxxxxxxxx";//Put here your API username
$password =  "xxxxxxxxxxxxxxxxxxxxx";//Put here your API password
$phone_number = "+256771234567";
$amount = 10000.00;
$transaction_ref = "xxx";//Some unique reference to the transaction
$narrative = "xxx"; //A description of the transaction
$successCallbackUrl = "https://example.com/success";//A call back once the transaction is successful
try {

    $ret = $wallet->deposit($phone_number,$amount,$transaction_ref,$narrative,$successCallbackUrl);
    //
}catch(\Exception $e){
    //Something wrong happened
    echo "Exception: ". $e->getMessage();
}


$transaction_ref = "xxx";//The unique identifier of the transaction
$username =  "xxxxxxxxxxxxxxxxxxxxx";//Put here your API username
$password =  "xxxxxxxxxxxxxxxxxxxxx";//Put here your API password
$wallet = new SsentezoWallet($username, $password);

try {
    $response = $wallet->checkStatus($prn);//The response object has all the information about the transaction
    //You can then find the status
    switch ($response->status) {
        case "SUCCEEDED": // For success
            break;
        case "FAILED": //Failed the transaction 
            break;
        case "PENDING": //Still Pending
            break;
        case "INDETERMINATE": //As the name suggests 
            break;
        default:// WTF
    }
} catch (Exception $e) {
    //Something went wrong
    echo "Exception: ".$e->getMessage();
            
}

use Codelords\SsentezoWallet;

$wallet = new SsentezoWallet($username, $password);
$username =  "xxxxxxxxxxxxxxxxxxxxx";//Put here your API username
$password =  "xxxxxxxxxxxxxxxxxxxxx";//Put here your API password
$phone_number = "+256771234567";
$amount = 10000.00;
$transaction_ref = "xxx";//Some unique reference to the transaction
$narrative = "xxx"; //A description of the transaction
$successCallbackUrl = "https://example.com/success";//A call back once the transaction is successful
 

try {

    $response = $wallet->withdraw($phone_number, $amount, $transaction_ref, $narrative, $successCallback);
    //
}catch(\Exception $e){
    //Something wrong happened
    echo "Exception: ". $e->getMessage();
}


$ cp vendor/code-lords/ssentezo-wallet/resources/example.php .