alvincoded/laravel-mtn-momo-ai 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alvincoded/laravel-mtn-momo-ai

最新稳定版本:v1.2.0

Composer 安装命令:

composer require alvincoded/laravel-mtn-momo-ai

包简介

A Laravel package for integrating MTN Mobile Money API with AI capabilities

README 文档

README

Latest Version on Packagist Code Style Security

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

  2. API Subscription

    • Subscribe to one or more MTN MOMO products:
      • Collections
      • Disbursements
      • Remittances
    • Get your Subscription Key from your developer profile

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)
  • Deepseek API Key (for Deepseek)

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+

You can install the package via composer:

composer require alvincoded/laravel-mtn-momo-ai

After installation, run the package's installation command:

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.

Environment Variables

# MTN MOMO API Configuration
MTN_MOMO_API_USER=your_api_user_id # Randomly generated UUID
MTN_MOMO_API_KEY=your_api_key
MTN_MOMO_SUBSCRIPTION_KEY=your_subscription_key
MTN_MOMO_PROVIDER_CALLBACK_HOST=http://localhost
MTN_MOMO_BASE_URL=https://sandbox.momodeveloper.mtn.com
MTN_MOMO_ENVIRONMENT=sandbox
MTN_MOMO_DEFAULT_CURRENCY=EUR

# AI Model API Keys
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key
GEMINI_API_KEY=your_gemini_key
DEEPSEEK_API_KEY=your_deepseek_key

# Default LLM Configuration
DEFAULT_LLM=ChatGPT
REPORTING_LLM=ChatGPT

# Alerting Configuration
MTN_MOMO_ALERT_EMAIL=alerts@example.com

Usage 🛠️

Basic Usage

use AlvinCoded\MtnMomoAi\Facades\MtnMomoAi;

// Analyze a transaction
$analysis = MtnMomoAi::analyzeTransaction('transaction123');

// Request to pay
$result = MtnMomoAi::requestToPay(100, 'EUR', 'ext123', 'party123', 'Payment', 'Note');

// Transfer (Disbursement)
$result = MtnMomoAi::transfer(100, 'EUR', 'ext123', 'party123', 'Payment', 'Note');

// Remittance
$result = MtnMomoAi::remit(100, 'EUR', 'ext123', 'party123', 'Payment', 'Note');

AI-Enhanced Features

// Detect fraud
$fraudAnalysis = MtnMomoAi::detectFraud($transactionData);

// Forecast cash flow
$forecast = MtnMomoAi::forecastCashFlow('1month');

// Parse natural language command
$result = MtnMomoAi::parseNaturalLanguageCommand('Send 100 EUR to John Doe');

// Generate report
$report = MtnMomoAi::generateReport($startDate, $endDate);

// Detect anomalies
$anomalies = MtnMomoAi::monitorTransactions();

Currency Configuration

// Using default currency
MtnMomoAi::scheduleDisbursement(100, 'recipient123');

// Specifying a different currency
MtnMomoAi::scheduleDisbursement(100, 'recipient123', 'EUR');

Transaction Analysis

// 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' => 'EUR',
    'recipient' => 'user123',
    'timestamp' => now(),
    'location' => 'GH'
]);

Smart Retry Mechanism

// Retry failed transaction with AI-optimized strategy
$retryResult = MtnMomoAi::smartRetry([
    'product' => 'collection',
    'amount' => 100,
    'currency' => 'EUR',
    'externalId' => 'ext123',
    'partyId' => 'party123',
    'payerMessage' => 'Payment',
    'payeeNote' => 'Note'
]);

Error Handling

The package includes comprehensive error handling:

try {
    $result = MtnMomoAi::requestToPay(100, 'EUR', '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

// 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:

composer test

Contributing 🤝

Contributions are welcome! Please see CONTRIBUTING.md for details.

Security 🔒

Please review our security policy on how to report security vulnerabilities.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits 👏

License 📄

The MIT License (MIT). Please see License File for more information.

Support 💬

For support, please open an issue in the GitHub repository.

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-08