1. Go to this page and download the library: Download malico/laravel-mesomb 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/ */
malico / laravel-mesomb example snippets
return [
/**
* Api Version
*
* @var string
*/
'version' => 'v1.0',
/**
* MeSomb Application Key
* Copy from https://mesomb.hachther.com/en/applications/{id}
*
* @var string
*/
'key' => env('MeSomb_APP_KEY'),
/**
* MeSomb API Application Key
* Copy from https://mesomb.hachther.com/en/applications/{id}
*
* @var string
*/
'api_key' => env('MeSomb_API_KEY'),
/**
* PIN used for MeSomb Pin
* Configure @ https://mesomb.hachther.com/en/applications/{id}/settings/setpin/
*
* @var int|string
*/
'pin' => env('MeSomb_PIN', null),
/**
* Supported Payment Methods
*
* @var array
*/
'currencies' => ['XAF', 'XOF'],
/**
* Support Payment Methods
* Array in order of preference
*
* @var array
*/
'services' => ['MTN', 'ORANGE'],
/**
* Set to True if your application uses uuid instead auto-incrmenting ids
*
* @var bool
*/
'uses_uuid' => false,
/*
* Used to store the application Status
*/
'application_cache_key' => 'mesomb_application_status',
/*
* You can choose to wait till the application to wait till the payment is approved
* or queue the payment request check later
* enum: asynchronous, synchronous
*/
'mode' => 'synchronous',
'throw_exceptions' => true,
];
// OrderController.php
use Malico\MeSomb\Payment;
class OrderController extends Controller {
public function confirmOrder()
{
$request = new Payment('+23767xxxxxxx', 1000);
$payment = $request->pay();
if($payment->success){
// Fire some event,Pay someone, Alert user
} else {
// fire some event, redirect to error page
}
// get Transactions details $payment->transactions
}
}
// Order.php
use Malico\MeSomb\Helper\HasPayments;
class Order extends Model
{
use HasPayments;
}
// OrderController.php
class OrderController extends Controller {
public function confirmOrder(){
$order = Order::create(['amount' => 100]);
$payment = $order->payment('+23767xxxxxxx', $order->amount)->pay();
if($payment->success){
// Fire some event,Pay someone, Alert user
} else {
// fire some event, redirect to error page
}
// View Order payments via $order->payments
// Get payment transaction with $payment->transaction
return $payment;
}
}