Download the PHP package akika/laravel-momo without Composer
On this page you can find all versions of the php package akika/laravel-momo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download akika/laravel-momo
More information about akika/laravel-momo
Files in akika/laravel-momo
Package laravel-momo
Short Description An unofficial package for MTN MoMo
License MIT
Homepage https://github.com/akika/laravel-momo
Informations about the package laravel-momo
Laravel MTN MoMo
An unofficial MTN MoMo integration for Laravel.
Installation
Install via Composer:
Optionally, publish the package config (and optional resources):
Configuration (.env)
You will need:
- A secondary key which you can retrieve from your MoMo developer account.
- A valid UUID for the
USER_REFERENCE_IDthrough a tool like https://www.uuidgenerator.net or via the cli:
Set environment variables below in your .env:
Note:
When usingsandboxmode, test using the Euro (EUR) currency, as that is the only currency that seems to work in sandbox mode.
For production, set:
- You can find all target environments on this page.
The full config file is at config/momo.php.
Creating an API User
You can create an API user using the provided Artisan command. The command will use the configured secondary key and user reference id from your config, or prompt for them.
Interactive (recommended):
Non-interactive (useful for CI or scripts):
After success, the API user will be registered with MTN, and you can retrieve it via php artisan momo:get-api-user (if available) or using the library API.
Creating an API Key
To create an API key for the registered API user run:
The command prints the environment variable you should set (for example MOMO_SANDBOX_API_KEY=...). Add that value to your .env for the current environment.
You can also run non-interactively:
Transferring Funds (Disbursement)
Use the provided MoMo facade or the MoMo class directly to perform disbursements. The disbursement() product exposes transfer() and getTransferStatus().
Example using the facade:
The method returns a reference/transaction id (string). You may use any value you like for externalId, but using a UUID or unique invoice id is recommended.
Checking Transfer Status
Call getTransferStatus() with the reference id returned from transfer():
$status is an array containing the provider response including the status and any metadata:
Inspect the returned array for fields like status, financialTransactionId, etc.
Facade / Programmatic Usage
You can instantiate Akika\\MoMo\\MoMo directly or use the provided facade Akika\\MoMo\\Facades\\MoMo.
Example using Akika\\MoMo\\MoMo:
Example using Akika\\MoMo\\Facades\\MoMo facade:
Checking the Account Balance
You can retrieve the MoMo account balance via the Disbursement product. The method returns an array with the available balance and currency.
Example using the MoMo facade:
Example using the MoMo class directly:
Check the returned array for availableBalance and currency when handling the response.
Overriding configuration programmatically
You can override configuration values at runtime either by constructing a MoMoConfig and passing it to a product, or by using the with() helper on the MoMo facade to create a client with temporary overrides.
Example — instantiate MoMoConfig and pass it to the Disbursement product:
Example — use the with() helper on the facade to create a client with overrides:
Callbacks
You can register an endpoint in your application to receive MoMo callbacks (for example, transfer/disbursement notifications). Add the route to routes/api.php or routes/web.php depending on whether you want it under the api middleware group.
Example route (add to routes/api.php):
Notes:
- Ensure your
MOMO_DISBURSMENT_CALLBACK_URLis set in your.envand reachable by MTN (use a public HTTPS URL in production; tools likengrokcan help during local development). - Consider validating incoming requests (signatures, known headers or a shared secret) before trusting the payload in production.
Sample callback payload for a disbursement:
The route above logs the callback payload with Laravel's info() helper and responds with a JSON success message. Adjust handling according to your application's needs (update transfer status, notify users, etc.).
Tests
Run tests with:
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Akika Digital
- All Contributors
License
The MIT License (MIT). See LICENSE.md.
All versions of laravel-momo with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0