You can install the package via composer:
composer require uzhlaravel/maishapayphp artisan maishapay:install
You can publish and run the migrations with:
php artisan vendor:publish --tag="maishapay-migrations"
php artisan migrateYou can publish the config file with:
php artisan vendor:publish --tag="maishapay-config"This is the contents of the published config file:
return [
'public_key' => env('MAISHAPAY_PUBLIC_KEY'),
'secret_key' => env('MAISHAPAY_SECRET_KEY'),
'gateway_mode' => env('MAISHAPAY_GATEWAY_MODE', 0),
];use Uzhlaravel\Maishapay\Maishapay;
use Uzhlaravel\Maishapay\Models\MaishapayTransaction;
use Uzhlaravel\Maishapay\DataTransferObjects\MobileMoney;
use Uzhlaravel\Maishapay\Exceptions\MaishapayException;
// you can use it as a parameter to a controller method
protected $maishapay;
public function __construct(Maishapay $maishapay)
{
$this->maishapay = $maishapay;
}
// for MOBILEMONEY payment type
// validating the request data
$validatedData = $request->validate([
'amount' => 'required|numeric',
'currency' => 'required|string',
'customerFullName' => 'required|string',
'customerEmailAddress' => 'required|email',
'provider' => 'required|string',
'walletID' => 'required',
'channel' => 'required|string',
]);
//if you want to keep track of the transaction
$transaction = MaishapayTransaction::create([
'payment_type' => 'MOBILEMONEY',
'provider' => $validatedData['provider'],
'amount' => $validatedData['amount'],
'currency' => $validatedData['currency'],
'customer_full_name' => $validatedData['customerFullName'],
'customer_email' => $validatedData['customerEmailAddress'],
'wallet_id' => $validatedData['walletID'],
'channel' => $validatedData['channel'],
'transaction_reference'=> 'TXN_' . uniqid(),
'status' => 'PENDING'
]);
//then do the transactin
$mobileMoney = new MobileMoney(
amount: $validatedData['amount'],
currency: $validatedData['currency'],
customerFullName: $validatedData['customerFullName'],
customerEmailAddress: $validatedData['customerEmailAddress'],
provider: $validatedData['provider'],
walletId: $validatedData['walletID'],
transactionReference: $transaction->transaction_reference,
callbackUrl: route('pricing')
);
// Process mobile money payment
$response = $this->maishapay->processMobileMoneyPayment($mobileMoney);
// Parse the response
$responseData = $response->json();
// or you can use implemetation directly in your controller method
$maishapay = new Uzhlaravel\Maishapay\Maishapay();
$response = $this->maishapay->processMobileMoneyPayment($mobileMoney);
...(other code)//importing the class
use Uzhlaravel\Maishapay\Maishapay;
use Uzhlaravel\Maishapay\Models\MaishapayTransaction;
use Uzhlaravel\Maishapay\DataTransferObjects\MobileMoney;
use Uzhlaravel\Maishapay\Exceptions\MaishapayException;
// you can use it as a parameter to a controller method
// for BANK payment type V2
// validating the request data
$validatedData = $request->validate([
'amount' => 'required|numeric',
'currency' => 'required|string',
'customerFullName' => 'required|string',
'customerEmailAddress' => 'required|email',
'provider' => 'required|string',
'walletID' => 'required',
'channel' => 'required|string',
]);
// if you want to keep track
$transaction = MaishapayTransaction::query()->create([
'payment_type' => 'CARD',
'provider' => $validatedData['provider'], //visa or mastercard
'amount' => $validatedData['amount'],
'currency' => $validatedData['currency'],
'customer_full_name' => $validatedData['customerFullName'],
'customer_phone' => $validatedData['customerPhoneNumber'],
'customer_email' => $validatedData['customerEmailAddress'],
'channel' => $validatedData['channel'],
'transaction_reference'=> 'TXN_' . uniqid(),
'status' => 'PENDING'
]);
$cardPayment = new CardPayment(
amount: $validatedData['amount'],
currency: $validatedData['currency'],
customerEmailAddress: $validatedData['customerEmailAddress'],
customerPhoneNumber: $validatedData['customerPhoneNumber'],
provider: $validatedData['provider'],
customerFullName: $validatedData['customerFullName'],
transactionReference: $transaction->transaction_reference,
callbackUrl: route('your-callback-route') // if different from the one in your .env file
);
$response = $this->maishapay->processCardPayment($cardPayment);
$responseData = $response->json();
//make sure to redirect to the payment page :
return redirect($responseData['paymentPage']);
(other code)composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.