定制 brunoadul/mpesa 二次开发

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

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

brunoadul/mpesa

最新稳定版本:v1.0.0

Composer 安装命令:

composer require brunoadul/mpesa

包简介

Mpesa payment integration for Bagisto

README 文档

README

This package provides M-Pesa payment integration for Bagisto e-commerce platform.

Installation

  1. Add the package to your Bagisto installation:
composer require brunoadul/mpesa
  1. Register the service provider in config/app.php:
'providers' => [
    // Other service providers...
    Brunoadul\Mpesa\Providers\MpesaServiceProvider::class,
],
  1. Publish the package assets:
php artisan vendor:publish --provider="Brunoadul\Mpesa\Providers\MpesaServiceProvider" --tag=mpesa-assets
php artisan vendor:publish --provider="Brunoadul\Mpesa\Providers\MpesaServiceProvider" --tag=mpesa-config
  1. Clear the cache:
php artisan cache:clear
php artisan config:clear
php artisan view:clear

Configuration

Environment Variables

Add the following environment variables to your .env file:

# M-Pesa Configuration
MPESA_SANDBOX=true
MPESA_BUSINESS_SHORTCODE=174379
MPESA_CONSUMER_KEY=your_consumer_key
MPESA_CONSUMER_SECRET=your_consumer_secret
MPESA_PASSKEY=your_passkey
MPESA_INITIATOR_NAME=your_initiator_name
MPESA_INITIATOR_PASSWORD=your_initiator_password

Sandbox Testing

For sandbox testing, you can use the following credentials:

  • Business Shortcode: 174379
  • Consumer Key: Get from Safaricom Developer Portal
  • Consumer Secret: Get from Safaricom Developer Portal
  • Passkey: Get from Safaricom Developer Portal

Production Configuration

For production, update your .env file with your production credentials:

MPESA_SANDBOX=false
MPESA_BUSINESS_SHORTCODE=your_production_shortcode
MPESA_CONSUMER_KEY=your_production_consumer_key
MPESA_CONSUMER_SECRET=your_production_consumer_secret
MPESA_PASSKEY=your_production_passkey
MPESA_INITIATOR_NAME=your_production_initiator_name
MPESA_INITIATOR_PASSWORD=your_production_initiator_password

Troubleshooting

Wrong Credentials Error

If you see "Failed to initiate STK push: Wrong credentials" error, check the following:

  1. Ensure your Consumer Key and Consumer Secret are correct
  2. Make sure your Business Shortcode is correct
  3. Verify that your Passkey is correct
  4. Check that you're using the correct environment (sandbox or production)

API Connection Issues

If you're having trouble connecting to the Safaricom API:

  1. Ensure your server can make outbound HTTPS requests
  2. Check that your server's SSL certificates are up to date
  3. Verify that your callback URL is publicly accessible

Support

For support, please contact me at brunoadul@gmail.com

License

This package is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-28