承接 yosinan/chapavel 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

yosinan/chapavel

最新稳定版本:1.0.0

Composer 安装命令:

composer require yosinan/chapavel

包简介

Custom Chapa Payment Integration for Laravel

README 文档

README

A custom Laravel package for seamless integration with Chapa payment gateway. Provides a clean API for initializing payments, verifying transactions, and handling secure webhooks.

Features

  • Easy Payment Initialization: Start payments with minimal code.
  • Webhook Verification: Securely verify Chapa webhooks using HMAC SHA256.
  • Transaction Status: Query and update payment status.
  • Idempotent Webhook Handling: Prevents duplicate processing on retries.

Installation

  1. Require the package:

    composer require yosinan/chapavel
  2. Publish the configuration file:

    php artisan vendor:publish --tag=chapa-config
  3. Add your Chapa keys to .env:

    CHAPA_SECRET_KEY=your_secret_key
    CHAPA_PUBLIC_KEY=your_public_key
    CHAPA_BASE_URL=https://api.chapa.co
    FRONTEND_URL=http://localhost:3000
    

Usage

Initialize Payment

use Yosinan\Chapavel\ChapaClient;

// Example: $payment is your payment model or array
$payload = [
    'amount'       => (string) $payment->amount,
    'currency'     => 'ETB',
    'email'        => $payment->email,
    'first_name'   => $payment->name,
    'tx_ref'       => $payment->tx_ref,
    'callback_url' => route('payment.return') . '?tx_ref=' . $payment->tx_ref,
    'return_url'   => route('payment.return') . '?tx_ref=' . $payment->tx_ref,
    'customization'=> [
        'title' => 'Order Payment',
        'description' => 'Checkout'
    ],
];

$chapa = new ChapaClient();
$response = $chapa->initialize($payload);
// $response['data']['checkout_url'] contains the payment URL

Verify Payment

$response = $chapa->verify($txRef);
// $response contains transaction details

Webhook Verification

use Yosinan\Chapavel\WebhookVerifier;

$isValid = WebhookVerifier::isValid($rawBody, $sig1, $sig2, $secretKey);
if (!$isValid) {
    // Handle invalid signature
}
  • Accepts both Chapa-Signature and x-chapa-signature headers.
  • Uses HMAC SHA256 with your secret key.

License

The MIT License (MIT). Please see License File for more information.

Support

For issues or feature requests, open an issue.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-08-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固