mak8tech/mobile-wallet-zm
Composer 安装命令:
composer require mak8tech/mobile-wallet-zm
包简介
A Laravel package for mobile money payments in Zambia (MTN, Airtel, Zamtel)
README 文档
README
A comprehensive Laravel package for integrating mobile money payment services in Zambia. This package supports MTN Mobile Money, Airtel Money, and Zamtel Kwacha, providing a unified API for all three providers.
Features
- Multi-provider Support: Seamlessly integrate with MTN, Airtel, and Zamtel
- Laravel Integration: Works with Laravel 12+ and includes a service provider, facade, and middleware
- Inertia.js & React Components: Ready-to-use TypeScript React components for payment forms
- Transaction Management: Complete lifecycle management for payment transactions
- Webhook Handling: Process payment notifications from all providers
- Configuration: Flexible configuration options for each provider
Installation
You can install the package via composer:
composer require mak8tech/mobile-wallet-zm
After installation, run the package installation command:
php artisan mobile-wallet:install
This will publish the necessary configuration files, migrations, and frontend components.
Manual Setup
You can also publish and run the migrations manually:
php artisan vendor:publish --tag="mobile-wallet-migrations"
php artisan migrate
Publish the configuration file:
php artisan vendor:publish --tag="mobile-wallet-config"
Publish the frontend components:
php artisan vendor:publish --tag="mobile-wallet-assets"
Configuration
After publishing the configuration file, you can find it at config/mobile_wallet.php. You'll need to set up your API credentials for each provider:
return [ // Default mobile money provider 'default' => env('MOBILE_WALLET_PROVIDER', 'mtn'), // Default currency 'currency' => env('MOBILE_WALLET_CURRENCY', 'ZMW'), // Default country code 'country_code' => env('MOBILE_WALLET_COUNTRY_CODE', 'ZM'), // MTN MoMo Configuration 'mtn' => [ 'base_url' => env('MTN_API_BASE_URL', 'https://sandbox.momodeveloper.mtn.com'), 'api_key' => env('MTN_API_KEY'), 'api_secret' => env('MTN_API_SECRET'), 'collection_subscription_key' => env('MTN_COLLECTION_SUBSCRIPTION_KEY'), 'disbursement_subscription_key' => env('MTN_DISBURSEMENT_SUBSCRIPTION_KEY'), 'environment' => env('MTN_ENVIRONMENT', 'sandbox'), ], // Airtel Money Configuration 'airtel' => [ 'base_url' => env('AIRTEL_API_BASE_URL', 'https://openapi.airtel.africa'), 'api_key' => env('AIRTEL_API_KEY'), 'api_secret' => env('AIRTEL_API_SECRET'), 'environment' => env('AIRTEL_ENVIRONMENT', 'sandbox'), ], // Zamtel Kwacha Configuration 'zamtel' => [ 'base_url' => env('ZAMTEL_API_BASE_URL', 'https://api.zamtel.com/kwacha'), 'api_key' => env('ZAMTEL_API_KEY'), 'api_secret' => env('ZAMTEL_API_SECRET'), 'environment' => env('ZAMTEL_ENVIRONMENT', 'sandbox'), ], // Webhook Configuration 'webhook' => [ 'secret' => env('MOBILE_WALLET_WEBHOOK_SECRET'), 'url_path' => env('MOBILE_WALLET_WEBHOOK_PATH', 'api/mobile-wallet/webhook'), ], ];
Add the corresponding environment variables to your .env file:
# Mobile Wallet General Config
MOBILE_WALLET_PROVIDER=mtn
MOBILE_WALLET_CURRENCY=ZMW
MOBILE_WALLET_COUNTRY_CODE=ZM
MOBILE_WALLET_WEBHOOK_SECRET=your-webhook-secret
# MTN MoMo Config
MTN_API_BASE_URL=https://sandbox.momodeveloper.mtn.com
MTN_API_KEY=your-mtn-api-key
MTN_API_SECRET=your-mtn-api-secret
MTN_COLLECTION_SUBSCRIPTION_KEY=your-mtn-collection-key
MTN_ENVIRONMENT=sandbox
# Airtel Money Config
AIRTEL_API_BASE_URL=https://openapi.airtel.africa
AIRTEL_API_KEY=your-airtel-api-key
AIRTEL_API_SECRET=your-airtel-api-secret
AIRTEL_ENVIRONMENT=sandbox
# Zamtel Kwacha Config
ZAMTEL_API_BASE_URL=https://api.zamtel.com/kwacha
ZAMTEL_API_KEY=your-zamtel-api-key
ZAMTEL_API_SECRET=your-zamtel-api-secret
ZAMTEL_ENVIRONMENT=sandbox
Usage
Backend Usage
You can use the facade to interact with the default provider:
use Mak8Tech\MobileWalletZm\Facades\MobileWallet; // Request a payment $result = MobileWallet::requestPayment( '0977123456', // Phone number 100.00, // Amount 'REF123', // Reference (optional) 'Payment for order #123' // Narration (optional) ); // Check transaction status $status = MobileWallet::checkTransactionStatus($transactionId);
To use a specific provider:
// Using a specific provider $result = MobileWallet::provider('airtel')->requestPayment( '0977123456', 100.00 );
Frontend Usage
The package includes a React component for payment forms. After publishing the assets, you can import and use the component:
import { PaymentForm } from "@/vendor/mobile-wallet-zm/components/payment-form"; function CheckoutPage() { const handleSuccess = (data) => { console.log("Payment initiated", data); // Handle successful payment initiation }; const handleError = (error) => { console.error("Payment failed", error); // Handle payment error }; return ( <div> <h1>Checkout</h1> <PaymentForm amount={100.0} onSuccess={handleSuccess} onError={handleError} providers={[ { id: "mtn", name: "MTN Mobile Money" }, { id: "airtel", name: "Airtel Money" }, { id: "zamtel", name: "Zamtel Kwacha" }, ]} /> </div> ); }
Handling Webhooks
The package automatically registers routes to handle webhooks from all providers. Make sure your webhook URL is properly configured in your provider dashboard:
https://your-app.com/api/mobile-wallet/webhook/mtn
https://your-app.com/api/mobile-wallet/webhook/airtel
https://your-app.com/api/mobile-wallet/webhook/zamtel
You can also use the provider-agnostic endpoint:
https://your-app.com/api/mobile-wallet/webhook
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
mak8tech/mobile-wallet-zm 适用场景与选型建议
mak8tech/mobile-wallet-zm 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 03 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Mak8Tech」 「mobile-wallet-zm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mak8tech/mobile-wallet-zm 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mak8tech/mobile-wallet-zm 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mak8tech/mobile-wallet-zm 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
Turn any PDF into a Pingen-ready A4 letter (generated address cover page + A4 normalisation + safe margins) and send it through the Pingen print & mail API. Laravel-first.
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 45
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-19