vp-trading/chapa-laravel 问题修复 & 功能扩展

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

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

vp-trading/chapa-laravel

Composer 安装命令:

composer require vp-trading/chapa-laravel

包简介

README 文档

README

Total Downloads Latest Stable Version License

Installation

To install the chapa-laravel package, follow these steps:

  1. Require the package via Composer:

    composer require vp-trading/chapa-laravel
  2. Publish the configuration, route, and migration files:

    php artisan vendor:publish --provider="Vptrading\ChapaLaravel\ChapaServiceProvider"

    The package comes with config, route, and migration files to help you get started quickly.

  3. Run the migration:

    php artisan migrate
  4. Configure your .env file: Add your Chapa API keys:

    CHAPA_SECRET_KEY=your_chapa_secret_key_here
    CHAPA_CALLBACK_URL=/vp/chapa/webhook
    CHAPA_WEBHOOK_SECRET=54LZzhZbPs7yreuS6bAw74zS0KE7P4Mt1fiqRx7wOL8OdjUQHjBqsIpkpT2rm43S
    CHAPA_REF_PREFIX=vp_chapa_
  5. Ready to use! You can now use the package in your Laravel application.

Usage

Before you start using this package you should know all amount must be put in cent values. The development of this package took standards from stripe. So for example if you want the amount be 100 Birr you will put 10000.

Here are some basic usage examples:

Initialize Payment

use Vptrading\ChapaLaravel\Facades\Chapa;
use VpTrading\ChapaLaravel\ValueObjects\User;
use VpTrading\ChapaLaravel\ValueObjects\Customization;
use Money\Money;

$response = Chapa::acceptPayment([
    Money::ETB(10000),
    new User(
        firstName: 'John',
        lastName: 'Doe',
        email: 'johndoe@example.com',
        phoneNumber: '0912345678'
    ),
    route('return-url'),
    new Customization(
        title: 'VP Solutions',
        description: 'This package is working like a charm.',
        logo: 'https://vptrading.et/wp-content/uploads/2023/08/cropped-VP-Logo-Symbol-White.png'
    )
]);

// Redirect user to payment page
return redirect($response->checkout_url);

The Customization in the acceptPayment() method is optional and can be left out.

Verify Payment

use Vptrading\ChapaLaravel\Facades\Chapa;

$tx_ref = 'unique-tx-ref-123';
$verification = Chapa::verify($tx_ref);

if ($verification->data['status'] === 'success') {
    // Payment was successful
}

Refund

use Vptrading\ChapaLaravel\Facades\Chapa;
use Money\Money;

$chapaRef = "APfxLoHHsl1eD";
Chapa::refund($chapaRef, Money::ETB(10000), 'Client Requested Refund');

The amount and reason in the refund method are optional and can be left null.

Webhook

Chapa sends webhooks for all payment-related events to your application. This package provides a default webhook controller to handle these events. You can extend or override the default controller Vptrading\ChapaLaravel\Http\Controllers\WebhookController::class to implement custom logic for different webhook events.

To customize webhook handling, create your own controller and update the route in your application as needed.

Default route for receiving webhook is: /vp/chapa/webhook

You can change the route by changing the CHAPA_CALLBACK_URL env variable.

class WebhookController extends ChapaWebhookController
{
    public function __invoke(Request $request)
    {
        parent::__invoke($request);

        // Handle your custom logic here.
    }
}

🚀 And that's it. Do your thing and Give us a star if this helped you.🚀

vp-trading/chapa-laravel 适用场景与选型建议

vp-trading/chapa-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 610 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 08 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「laravel」 「vp」 「chapa」 「VPTrading」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 vp-trading/chapa-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 vp-trading/chapa-laravel 我们能提供哪些服务?
定制开发 / 二次开发

基于 vp-trading/chapa-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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