malipopay/laravel
Composer 安装命令:
composer require malipopay/laravel
包简介
Official Laravel package for Malipopay - Service Provider, Facade, Blade directives, Eloquent model, and webhook handling for mobile money, bank, card, and USSD payments in Tanzania
README 文档
README
Official Laravel integration for Malipopay. Service Provider, Facade, Eloquent models, Blade directives, webhook handling, and artisan commands for accepting payments in Tanzania via Mobile Money, Bank Transfer, USSD, and Card.
Wraps the malipopay/malipopay-php SDK with Laravel conveniences.
Installation
composer require malipopay/laravel
Install the config and migrations:
php artisan malipopay:install
Add to .env:
MALIPOPAY_API_KEY=your_api_key_here MALIPOPAY_ENVIRONMENT=uat MALIPOPAY_WEBHOOK_SECRET=your_webhook_secret
Quick Start
Collect a payment
use Malipopay\Laravel\Facades\Malipopay; $payment = Malipopay::collect([ 'description' => 'Order #1234', 'amount' => 10000, 'phoneNumber' => '255712345678', ]); // $payment is an Eloquent MalipopayPayment model — already saved in your DB echo $payment->reference; echo $payment->status; echo $payment->link;
Disburse funds
Malipopay::disburse([ 'description' => 'Salary payment', 'amount' => 50000, 'phoneNumber' => '255712345678', ]);
Verify a payment
$payment = Malipopay::verify('PAY-abc123');
Create a payment link
$link = Malipopay::createPaymentLink([ 'amount' => 25000, 'phoneNumber' => '255712345678', ]); return redirect($link->link);
Access any resource from the underlying SDK
$customers = Malipopay::customers->list(); $invoice = Malipopay::invoices->create([...]); Malipopay::sms->send([...]);
Webhooks
The package registers a POST route at /webhooks/malipopay automatically (configurable). It verifies the signature, stores the event, updates the payment model, and fires Laravel events you can listen to.
Listen to events
// app/Providers/EventServiceProvider.php use Malipopay\Laravel\Events\PaymentCompleted; use Malipopay\Laravel\Events\PaymentFailed; use App\Listeners\FulfillOrder; protected $listen = [ PaymentCompleted::class => [FulfillOrder::class], PaymentFailed::class => [NotifyCustomerPaymentFailed::class], ];
Listener example
use Malipopay\Laravel\Events\PaymentCompleted; class FulfillOrder { public function handle(PaymentCompleted $event): void { $payment = $event->payment; // MalipopayPayment model // update your order, send confirmation email, etc. } }
Available events
| Event | Fired when |
|---|---|
PaymentCompleted |
Collection successfully completed |
PaymentFailed |
Collection failed, reversed, or cancelled |
DisbursementCompleted |
Disbursement successfully completed |
WebhookReceived |
Catch-all, fired for every verified webhook |
Eloquent Model
MalipopayPayment stores every payment made through the package.
use Malipopay\Laravel\Models\MalipopayPayment; $pending = MalipopayPayment::pending()->count(); $completed = MalipopayPayment::completed()->whereDate('created_at', today())->sum('amount'); $payment = MalipopayPayment::where('reference', 'PAY-123')->first(); if ($payment->isCompleted()) { // ... }
Blade Directives
{{-- Insert a checkout button --}} @malipopayCheckout(['amount' => 10000, 'phone' => '255712345678', 'description' => 'Order #1234']) {{-- Format an amount --}} <span>@malipopayAmount(10000)</span> {{-- TZS 10,000 --}} <span>@malipopayAmount(10000, 'USD')</span> {{-- USD 10,000 --}}
Artisan Commands
# Install config and migrations php artisan malipopay:install # Send a test payment (use UAT) php artisan malipopay:test 255712345678 --amount=100 --description="Test"
Configuration
After publishing the config file (config/malipopay.php), you can customize:
- API key and environment
- Timeout and retry behavior
- Webhook path, signature header, and event storage
- Which Eloquent model to use (extend
MalipopayPayment) - Whether to auto-register webhook routes
Requirements
- PHP 8.1+
- Laravel 10, 11, or 12
- Malipopay API key (get one here)
License
MIT
See Also
| SDK | Install |
|---|---|
| Laravel (this package) | composer require malipopay/laravel |
| PHP (raw SDK) | composer require malipopay/malipopay-php |
| Node.js | npm install malipopay |
| Python | pip install malipopay |
| Java | Maven / Gradle |
| .NET | dotnet add package Malipopay |
| Ruby | gem install malipopay |
| Flutter/Dart | flutter pub add malipopay |
| React | npm install @malipopay/react |
malipopay/laravel 适用场景与选型建议
malipopay/laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「laravel」 「mpesa」 「payment-gateway」 「fintech」 「mobile-money」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 malipopay/laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 malipopay/laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 malipopay/laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Beyonic PHP Library
Alfabank REST API integration
Mpesa driver for omnipay payment processing library
Laravel package for Accurate Online API integration.
Official Safaricom Daraja M-Pesa integration for Laravel built on ysg/payment-core.
TrinkPOS Sanal POS (Virtual POS) API client for PHP
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 44
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-21