定制 malipopay/laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

malipopay/laravel

最新稳定版本:v1.0.0

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

API Reference | OpenAPI Spec

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固