PHP code example of hachther / laravel-mesomb

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

    

hachther / laravel-mesomb example snippets


// OrderController.php
use Hachther\MeSomb\Operation\Payment\Collect;

class OrderController extends Controller {

    public function confirmOrder()
    {
        $request = new Collect('67xxxxxxx', 1000, 'MTN', 'CM');

        $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
    }
}

// OrderController.php
use Hachther\MeSomb\Operation\Payment\Deposit;

class OrderController extends Controller {

    public function makeDeposit()
    {
        $request = new Deposit('67xxxxxxx', 1000, 'MTN', 'CM');

        $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 Hachther\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('67xxxxxxx', $order->amount, 'MTN', 'CM')->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;
    }
}

// OrderController.php
use Hachther\MeSomb\Operation\Payment\Collect;

class OrderController extends Controller {

    public function confirmOrder()
    {
        $request = new Collect('67xxxxxxx', 1000, 'MTN', 'CM');

        // Update applicationKey before process the payment
        // You also have setAccessKey and setSecretKey
        $payment = $request->setApplicationKey('<applicationKey>')->pay();

        if($payment->success){
            // Fire some event,Pay someone, Alert user
        } else {
            // fire some event, redirect to error page
        }

        // get Transactions details $payment->transactions
    }
}
shell
php artisan vendor:publish --tag=mesomb-configuration
shell
php artisan migrate