Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alvincoded/laravel-mtn-momo-ai
A powerful Laravel package that integrates MTN Mobile Money API with AI capabilities, providing intelligent transaction analysis, fraud detection, and more!
https://github.com/alvincoded/laravel-mtn-momo-ai
ai artifiical-intelligence claude gemini gpt laravel llm mtn mtn-mobile-money mtnmobilemoney mtnmomo
Last synced: 5 days ago
JSON representation
A powerful Laravel package that integrates MTN Mobile Money API with AI capabilities, providing intelligent transaction analysis, fraud detection, and more!
- Host: GitHub
- URL: https://github.com/alvincoded/laravel-mtn-momo-ai
- Owner: AlvinCoded
- License: mit
- Created: 2025-01-07T10:41:06.000Z (7 days ago)
- Default Branch: main
- Last Pushed: 2025-01-08T09:25:23.000Z (6 days ago)
- Last Synced: 2025-01-08T09:29:19.191Z (6 days ago)
- Topics: ai, artifiical-intelligence, claude, gemini, gpt, laravel, llm, mtn, mtn-mobile-money, mtnmobilemoney, mtnmomo
- Language: PHP
- Homepage:
- Size: 57.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Laravel MTN MOMO AI
[![Latest Version on Packagist](https://img.shields.io/packagist/v/AlvinCoded/laravel-mtn-momo-ai.svg?style=flat-square)](https://packagist.org/packages/alvincoded/laravel-mtn-momo-ai)
[![Total Downloads](https://img.shields.io/packagist/dt/AlvinCoded/laravel-mtn-momo-ai.svg?style=flat-square)](https://packagist.org/packages/alvincoded/laravel-mtn-momo-ai)
[![License](https://img.shields.io/packagist/l/AlvinCoded/laravel-mtn-momo-ai.svg?style=flat-square)](https://packagist.org/packages/alvincoded/laravel-mtn-momo-ai)A powerful Laravel package that integrates MTN Mobile Money API with AI capabilities, providing intelligent transaction analysis, fraud detection, and more!
## Features ๐
- ๐ณ Seamless integration with MTN MOMO API (Collections, Disbursements, Remittances)
- ๐ง AI-powered transaction analysis using multiple LLM models (ChatGPT, Claude, Gemini)
- ๐ต๏ธ Intelligent fraud detection
- ๐ Cash flow forecasting
- ๐ Smart retry mechanisms for failed transactions
- ๐ Natural language command parsing
- ๐ Automated reporting
- โฑ๏ธ Smart disbursement scheduling
- ๐จ Anomaly detection in transactions
- ๐ง API call optimization## Prerequisites ๐
Before getting started with the MTN MOMO AI package, you'll need:
### MTN MOMO API Requirements
1. **MTN MOMO Developer Account**
- Sign up at [MTN MOMO Developer Portal](https://momodeveloper.mtn.com/signup)
- Complete the verification process
- Store your API credentials safely2. **API Subscription**
- Subscribe to one or more MTN MOMO products:
- Collections
- Disbursements
- Remittances
- Get your Subscription Key from your [developer profile](https://momodeveloper.mtn.com/developer)### AI Model Requirements
You'll need at least one of these API keys:
- OpenAI API Key (for ChatGPT)
- Anthropic API Key (for Claude)
- Google Gemini API Key (for Gemini)### System Requirements
- PHP 8.1 or higher
- Laravel 9.x|10.x|11.x
- Composer### Environment Setup
Make sure your server/hosting environment:
- Allows outbound HTTPS connections
- Has sufficient memory for AI operations
- Supports background job processing (for notifications)
## Installation ๐ฆ
> **Requires [PHP 8.1+](https://php.net/releases/)**
You can install the package via composer:
```bash
composer require alvincoded/laravel-mtn-momo-ai
```After installation, run the package's installation command:
```bash
php artisan mtn-momo-ai:install
```This command will guide you through the setup process, including publishing the configuration file and setting up your environment variables.
## Configuration โ๏ธ
The package configuration file will be published to `config/mtn-momo-ai.php`. You can modify the settings there or use environment variables in your `.env` file.
Key configurations include:
- MTN MOMO API credentials
- AI model settings (ChatGPT, Claude, Gemini)
- Default LLM selection
- Alerting settings### Environment Variables
```bash
# MTN MOMO API Configuration
MTN_MOMO_API_USER=your_api_user
MTN_MOMO_API_KEY=your_api_key
MTN_MOMO_SUBSCRIPTION_KEY=your_subscription_key
MTN_MOMO_BASE_URL=https://sandbox.momodeveloper.mtn.com
MTN_MOMO_ENVIRONMENT=sandbox
MTN_MOMO_DEFAULT_CURRENCY=USD# AI Model API Keys
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key
GEMINI_API_KEY=your_gemini_key# Default LLM Configuration
DEFAULT_LLM=ChatGPT
REPORTING_LLM=ChatGPT# Alerting Configuration
[email protected]
```## Usage ๐ ๏ธ
### Basic Usage
```php
use AlvinCoded\MtnMomoAi\Facades\MtnMomoAi;// Analyze a transaction
$analysis = MtnMomoAi::analyzeTransaction('transaction123');// Request to pay
$result = MtnMomoAi::requestToPay(100, 'GHS', 'ext123', 'party123', 'Payment', 'Note');// Transfer (Disbursement)
$result = MtnMomoAi::transfer(100, 'GHS', 'ext123', 'party123', 'Payment', 'Note');// Remittance
$result = MtnMomoAi::remit(100, 'GHS', 'ext123', 'party123', 'Payment', 'Note');
```### AI-Enhanced Features
```php
// Detect fraud
$fraudAnalysis = MtnMomoAi::detectFraud($transactionData);// Forecast cash flow
$forecast = MtnMomoAi::forecastCashFlow('1month');// Parse natural language command
$result = MtnMomoAi::parseNaturalLanguageCommand('Send 100 GHS to John Doe');// Generate report
$report = MtnMomoAi::generateReport($startDate, $endDate);// Detect anomalies
$anomalies = MtnMomoAi::monitorTransactions();
```### Currency Configuration
```php
// Using default currency
MtnMomoAi::scheduleDisbursement(100, 'recipient123');// Specifying a different currency
MtnMomoAi::scheduleDisbursement(100, 'recipient123', 'GHS');
```### Transaction Analysis
```php
// Detailed transaction analysis
$analysis = MtnMomoAi::analyzeTransaction('transaction123');
// Returns AI-powered insights about the transaction// Fraud detection with custom parameters
$fraudAnalysis = MtnMomoAi::detectFraud([
'amount' => 1000,
'currency' => 'GHS',
'recipient' => 'user123',
'timestamp' => now(),
'location' => 'GH'
]);
```### Smart Retry Mechanism
```php
// Retry failed transaction with AI-optimized strategy
$retryResult = MtnMomoAi::smartRetry([
'product' => 'collection',
'amount' => 100,
'currency' => 'GHS',
'externalId' => 'ext123',
'partyId' => 'party123',
'payerMessage' => 'Payment',
'payeeNote' => 'Note'
]);
```### Error Handling
The package includes comprehensive error handling:
```php
try {
$result = MtnMomoAi::requestToPay(100, 'GHS', 'ext123', 'party123', 'Payment', 'Note');
} catch (\AlvinCoded\MtnMomoAi\Exceptions\MtnMomoApiException $e) {
// Handle API-specific errors
$errorDetails = $e->getResponseBody();
} catch (\Exception $e) {
// Handle general errors
}
```### AI Model Selection
```php
// Use default model from config
$analysis = MtnMomoAi::analyzeTransaction('transaction123');// Specify a particular model
$analysis = MtnMomoAi::analyzeTransaction('transaction123', 'Claude');
$fraudCheck = MtnMomoAi::detectFraud($transactionData, 'Gemini');
$forecast = MtnMomoAi::forecastCashFlow('1month', 'ChatGPT');```
## API Reference ๐
### MTN MOMO API Methods
- `requestToPay($amount, $currency, $externalId, $partyId, $payerMessage, $payeeNote)`
- `getCollectionTransactionStatus($referenceId)`
- `getAccountBalance()`
- `getAccountHolder($accountHolderId, $accountHolderIdType)`
- `transfer($amount, $currency, $externalId, $payee, $payerMessage, $payeeNote)`
- `getDisbursementTransactionStatus($referenceId)`
- `remit($amount, $currency, $externalId, $payee, $payerMessage, $payeeNote)`
- `getRemittanceTransactionStatus($referenceId)`### AI-Enhanced Methods
- `analyzeTransaction($transactionId)`
- `detectFraud($transactionData)`
- `smartRetry($failedTransaction)`
- `forecastCashFlow($timeframe)`
- `parseNaturalLanguageCommand($command)`
- `generateReport($startDate, $endDate)`
- `scheduleDisbursement($amount, $recipient)`
- `monitorTransactions()`
- `optimizeApiCalls($endpoint)`
- `handleError($errorCode, $context)`## Testing ๐งช
To run the package tests:
```bash
composer test
```## Contributing ๐ค
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
## Security ๐
If you discover any security-related issues, don't hesitate to use the issue tracker.
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Credits ๐
- Author: [Alvin Panford](https://github.com/AlvinCoded)
- OpenAI PHP by [Nuno Maduro](https://github.com/openai-php/laravel)
- Anthropic Laravel by [Mozex](https://github.com/mozex/anthropic-laravel)
- **Gemini PHP** for Laravel by [Fatih AYDIN](https://github.com/google-gemini-php/laravel)## License ๐
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
## Support ๐ฌ
For support, please open an issue in the GitHub repository.