Laravel Wrapper on top of MeSomb Payment API
API Features and their implementations https://mesomb.hachther.com/en/api/schema/
Feature | Status |
---|---|
Payment | ☑ |
Transaction Status | ☑ |
Application Status | ☑ |
Deposits | ☑ |
Test | ☐ |
Better Documentation | ☐ |
Install Package
composer require malico/laravel-mesomb
Publish Configuration Files
php artisan vendor:publish --tag=mesomb-configuration
Sign up and Create new Application at https://mesomb.hachther.com/. Provide appropriate from your dashboard configure for the config/mesomb.php
;
<?php
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,
];
Migrate Mesomb Transaction Tables
php artisan migrate
Examples
-
Simple Payments
// 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 } }
-
Attaching Payments to Models Directly
// 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; } }
Malico (Desmond Yong) hi@malico.me