1. Go to this page and download the library: Download cyrus-48/paysasa 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/ */
use Illuminate\Support\Facades\Event;
use Paysasa\Payments\Events\PaymentSuccessful;
use Paysasa\Payments\Events\PaymentFailed;
use Paysasa\Payments\Events\PaymentExpired;
// In your EventServiceProvider or listener:
Event::listen(PaymentSuccessful::class, function (PaymentSuccessful $event) {
$payment = $event->payment;
// Dispatch order, send SMS receipt, update subscription...
});
Event::listen(PaymentFailed::class, function (PaymentFailed $event) {
// Alert customer, log failure reason...
});
use Paysasa\Payments\Facades\Payment;
Payment::fake();
// Run your application code...
$user->checkout();
// Assertions:
Payment::assertCharged(fn ($request) => $request->amountMajor() === 2500.0);
Payment::assertChargedOn('mpesa');
Payment::assertChargedTimes(1);
Payment::fake([
PaymentResponse::makeFailed(PaymentProvider::Mpesa, message: 'DS timeout user cannot be reached'),
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.