Momo Suite
  • Introduction
  • Getting Started
  • Basic Concepts
  • Providers (Hubtel)
    • Korba
    • PayStack
    • ITC
  • Dashboard (Overview)
    • Transaction Detail Page
      • Status Check for Pending Transactions
      • Manual Status Update (Admin Only)
      • Transaction Timeline
      • Technical Details
  • User Management
  • Transaction Status Update Notifications
Powered by GitBook
On this page
  • Overview
  • How to Listen for Transaction Status Updates
  • Example Use Cases
  • Advanced: Multiple Listeners
  • Troubleshooting
  • Summary

Transaction Status Update Notifications

Overview

Momo Suite dispatches a TransactionStatusUpdated event every time a transaction’s status is updated—whether by webhook, manual update, or status check.This allows you to easily listen for transaction status changes and perform custom actions, such as logging, sending emails, or SMS notifications.


How It Works

  • Event: Rais\MomoSuite\Events\TransactionStatusUpdated

  • Dispatched: Whenever a transaction’s status is updated by the package.

  • Payload: The event includes the transaction, the old status, and the new status.


How to Listen for Transaction Status Updates

Create a listener class in your app, for example at app/Listeners/LogTransactionStatusUpdate.php:

  1. Create a Listener

namespace App\Listeners;

use Rais\MomoSuite\Events\TransactionStatusUpdated;
use Illuminate\Support\Facades\Log;

class LogTransactionStatusUpdate
{
    public function handle(TransactionStatusUpdated $event)
    {
        Log::info('Transaction status updated', [
            'transaction_id' => $event->transaction->transaction_id,
            'old_status' => $event->oldStatus,
            'new_status' => $event->newStatus,
        ]);
        // You can also send an email, SMS, or trigger other notifications here!
    }
}
  1. Register the Listener

In your app/Providers/EventServiceProvider.php, add:

protected $listen = [
    \Rais\MomoSuite\Events\TransactionStatusUpdated::class => [
        \App\Listeners\LogTransactionStatusUpdate::class,
    ],
];

Then run:

php artisan event:cache
  1. React to Status Changes

Now, whenever a transaction’s status is updated, your listener will be triggered automatically.You can perform any action you want in the handle method—log, notify, update other systems, etc.

Example Use Cases

  • Send an email or SMS to the user when their transaction status changes.

  • Log all status changes for auditing.

  • Trigger business logic in your own application.


Advanced: Multiple Listeners

You can register multiple listeners for the same event if you want to perform several actions.


Troubleshooting

  • Make sure your listener is registered in EventServiceProvider.

  • Check your logs (storage/logs/laravel.log) to confirm the listener is being triggered.

  • If you use event caching, run php artisan event:cache after making changes.


Summary

Momo Suite makes it easy to react to transaction status changes in a scalable, Laravel-native way.Just listen for the TransactionStatusUpdated event and add your custom logic!

PreviousUser Management

Last updated 1 month ago