1. Go to this page and download the library: Download yves/mopay 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/ */
namespace App;
use Illuminate\Database\Eloquent\Model;
use Yves\Mopay\Traits\MopayTrait; //
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Passenger;
class PassengerPaymentController extends Controller
{
public function initiatePayment(Passenger $passenger){
$payment = $passenger->pay(1000);// 1000 is the amount to be requested from this passenger
if($payment){
return "payment successfuly initiated";
}
}
}
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Passenger;
use Yves\Mopay\Utils\PaymentCart;
use Yves\Mopay\Utils\PaymentForm;
use Yves\Mopay\Utils\PaymentFormItem;
use Yves\Mopay\Utils\PaymentProductCart;
class PassengerPaymentController extends Controller
{
// show user a form to fill in phone number
public function showPaymentForm(Request $request){
//initialize payment form
$paymentForm = new PaymentForm();
// adding items
$paymentForm->addItem(new PaymentFormItem(PaymentFormItem::AMOUNT,"1000"));
$paymentForm->addItem(new PaymentFormItem(PaymentFormItem::CURRENCY,"Rwf"));
$paymentForm->addItem(new PaymentFormItem(PaymentFormItem::MSISDN,"250783588655",false));
$paymentForm->addItem(new PaymentFormItem(PaymentFormItem::CLIENT_NAME,"Mukunzi Joshua"));
$paymentForm->addItem(new PaymentFormItem(PaymentFormItem::EMAIL,"[email protected]"));
$paymentCart = new PaymentCart();// if you wish to show cart on the sibar if template view
$paymentCart->addProduct(new PaymentProductCart("Ticket",1000));// adding product to cart
$paymentForm->setCart($paymentCart);// set payment cart
return $paymentForm->view();// this will return view for the payment
}
}
bash
$ php artisan mopay:install
bash
$ php artisan migrate
bash
$ php artisan queue:work
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.