codelords / ssentezo-wallet
A package to help integrate ssentezo wallet into your php application
Requires
- php: >=5.6
- mashape/unirest-php: ^3.0
Requires (Dev)
- phpunit/phpunit: ^4.6
- dev-main
- v2.0.04
- v2.0.03
- v2.0.02
- v2.0.01
- v2.0.0
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.0.2
- v0.0.1
- dev-19-push-to-bank
- dev-16-wallet-version-2
- dev-daakibenja-patch-3
- dev-daakibenja-patch-2
- dev-daakibenja-patch-1
- dev-12-some-cases-of-check-status-not-handled
- dev-10-what-about-implentation-examples
- dev-dev
This package is auto-updated.
Last update: 2024-10-30 18:09:10 UTC
README
A package to help integrate ssentezo wallet into your php application
Getting started
- Create a ssentezo wallet account
Installation
The recommended way to install ssentezo wallet is through Composer:
$ composer require codelords/ssentezo-wallet
After ssentezo wallet installs, you can copy an example file to the project root.
$ cp vendor/code-lords/ssentezo-wallet/resources/example.php .
Making tranasactions
To make transactions you only need to create an instance of the ssentezo wallet
use Codelords\SsentezoWallet; $username = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; $password = "zzzzzzzzzzzzzzzzzzzzzzzzzzzz"; $wallet = new SentezoWallet($username, $password);
With the wallet object you can easily check balance, make deposits withdrawals and as well check status of a transaction.
Configurations
Before we look at how you can make transactions, Let's first look at the configurations.
/** * 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");
Here is a list of all the possible configurations and the various methods you can use to manipulate them.
Making a deposit
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(); }
Check Status of Transaction
$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(); }
Making a Withrawal
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(); }