1. Go to this page and download the library: Download mathermann/dohone-sdk 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/ */
mathermann / dohone-sdk example snippets
php
namespace Your\Name\Space; // Replace with your namespace
use Mathermann\DohoneSDK\TransactionInterface;
class Transaction implements TransactionInterface
{
/**
* Transaction reference (or id) in your system
*/
private $transactionRef;
/**
* Transaction operator, must be one of the following values:
* ['DOHONE_MOMO', 'DOHONE_OM', 'DOHONE_EU', 'DOHONE_TRANSFER']
*/
private $transactionOperator;
private $transactionAmount;
/**
* Transaction currency, must be one of the following values:
* ['XAF', 'EUR', 'USD']
*/
private $transactionCurrency;
private $transactionReason;
/**
* Transaction reference in Dohone's system
*/
private $dohoneTransactionRef;
private $customerName;
private $customerPhoneNumber;
private $customerEmail;
private $customerCountry;
private $customerCity;
/**
* Notification URL for this transaction
*/
private $notifyUrl;
// You can add some additional properties...
public function getTransactionRef()
{
return $this->transactionRef;
}
public function getTransactionOperator()
{
return $this->transactionOperator;
}
public function getTransactionAmount()
{
return $this->transactionAmount;
}
public function getTransactionCurrency()
{
return $this->transactionCurrency;
}
public function getTransactionReason()
{
return $this->transactionReason;
}
public function getDohoneTransactionRef()
{
return $this->dohoneTransactionRef;
}
public function getCustomerName()
{
return $this->customerName;
}
public function getCustomerPhoneNumber()
{
return $this->customerPhoneNumber;
}
public function getCustomerEmail()
{
return $this->customerEmail;
}
public function getCustomerCountry()
{
return $this->customerCountry;
}
public function getCustomerCity()
{
return $this->customerCity;
}
public function getNotifyUrl()
{
return $this->notifyUrl;
}
// add setters...
// you can add some additional methods...
}
php
use Mathermann\DohoneSDK\DohoneSDK;
// constants
define('MERCHANT_KEY', '...'); // your dohone merchant key (your dohone hash code (only if you handle dohone notifications in your system)
define('NOTIFY_URL', '...'); // default notification URL for incoming payments
$dohoneSdk = new DohoneSDK(MERCHANT_KEY, APP_NAME, HASH_CODE, NOTIFY_URL);
// ...
php
// ...
use Mathermann\DohoneSDK\InvalidDohoneResponseException;
try
{
/**
* $transaction is an object of type Transaction defined above,
* $mode is exactly the same as "levelFeeds" in Dohone's documentation
*/
$response = $dohoneSdk->quote($transaction, ['mode' => $mode]);
if ($response->isSuccess())
{
echo $response->getMessage(); // display result
}
else
{
echo $response->getMessage(); // display error message
}
}
catch (InvalidDohoneResponseException $e)
{
echo $e->getMessage(); // display error message
}
// ...
php
// ...
use Mathermann\DohoneSDK\InvalidDohoneResponseException;
try
{
/**
* $transaction is an object of type Transaction defined above,
* $OTP is exactly the same as "rOTP" in Dohone's documentation, eedCFRMSMS()) {
// ToDo: request SMS confirmation code to user
}
}
else
{
echo $response->getMessage(); // display error message
}
}
catch (InvalidDohoneResponseException $e)
{
echo $e->getMessage(); // display error message
}
// ...
php
// ...
use Mathermann\DohoneSDK\InvalidDohoneResponseException;
try
{
/**
* $transaction is an object of type Transaction defined above,
* $code is exactly the same as "rCS" in Dohone's documentation
*/
$response = $dohoneSdk->confirmSMS($transaction, ['code' => $code]);
if ($response->isSuccess())
{
if ($response->hasREF()) {
// ToDo: handle success
}
else if ($response->needCFRMSMS()) {
// ToDo: request SMS confirmation code to user
}
}
else
{
echo $response->getMessage(); // display error message
}
}
catch (InvalidDohoneResponseException $e)
{
echo $e->getMessage(); // display error message
}
// ...
php
// ...
use Mathermann\DohoneSDK\InvalidDohoneResponseException;
try
{
/**
* $transaction is an object of type Transaction defined above
*/
$response = $dohoneSdk->verify($transaction);
if ($response->isSuccess()) {
// ToDo: handle OK
}
else {
// ToDo: handle NO
}
}
catch (InvalidDohoneResponseException $e)
{
echo $e->getMessage(); // display error message
}
// ...
php
use Mathermann\DohoneSDK\DohonePayoutSDK;
// constants
define('ACCOUNT', '...'); // the phone number of your Dohone account (ohonePayoutSdk = new DohonePayoutSDK(ACCOUNT, HASH_CODE, NOTIFY_URL);
// ...
php
// ...
use Mathermann\DohoneSDK\InvalidDohoneResponseException;
try
{
/**
* $transaction is an object of type Transaction defined above
*/
$response = $dohonePayoutSdk->quote($transaction);
if ($response->isSuccess())
{
echo $response->getMessage(); // display result
}
else
{
echo $response->getMessage(); // display error message
}
}
catch (InvalidDohoneResponseException $e)
{
echo $e->getMessage(); // display error message
}
// ...
php
// ...
use Mathermann\DohoneSDK\InvalidDohoneResponseException;
try
{
/**
* $transaction is an object of type Transaction defined above
*/
$response = $dohonePayoutSdk->transfer($transaction);
if ($response->isSuccess() && $response->hasREF()) {
// ToDo: handle success
}
else {
echo $response->getMessage(); // display error message
}
}
catch (InvalidDohoneResponseException $e)
{
echo $e->getMessage(); // display error message
}
// ...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.