chitanga/pesepay 问题修复 & 功能扩展

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

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

chitanga/pesepay

最新稳定版本:v1.0.0

Composer 安装命令:

composer require chitanga/pesepay

包简介

Seamless Pesepay integration package

README 文档

README

Pesepay Payment Gateway for Laravel Latest Version on Packagist GitHub Tests Action Status Total Downloads

A comprehensive Laravel package for integrating Pesepay payment gateway into your application. This package provides seamless Ecocash and card payment processing with robust error handling and status checking.

Features

Ecocash payments integration

Card payments processing

Payment status verification

Comprehensive exception handling

Configurable through environment variables

Installation

You can install the package via composer:

composer require chitanga/pesepay

You can publish with:

php artisan vendor:publish --tag="pesepay-config"

You can publish the config file with:

php artisan vendor:publish --tag=":package_slug-config"

This is the contents of the published config file:

return [
    /*
    |--------------------------------------------------------------------------
    | API Credentials
    |--------------------------------------------------------------------------
    */
    'integration_key' => env('PESEPAY_INTEGRATION_KEY'),
    'encryption_key' => env('PESEPAY_ENCRYPTION_KEY'),

    /*
    |--------------------------------------------------------------------------
    | Payment URLs
    |--------------------------------------------------------------------------
    */
    'return_url' => env('PESEPAY_RETURN_URL'),
    'result_url' => env('PESEPAY_RESULT_URL'),

    /*
    |--------------------------------------------------------------------------
    | Default Settings
    |--------------------------------------------------------------------------
    */
    'default_currency' => 'USD',
    'brand_name' => env('PESEPAY_BRAND_NAME', env('APP_NAME', 'Laravel')),

];

Configuration Add these environment variables to your .env file:

PESEPAY_INTEGRATION_KEY=your_integration_key
PESEPAY_ENCRYPTION_KEY=your_encryption_key
PESEPAY_RETURN_URL=https://your-app.com/return
PESEPAY_RESULT_URL=https://your-app.com/webhook
PESEPAY_BRAND_NAME="Your Business Name"

Usage

use Chitanga\Pesepay\PesepayService;

$pesepay = new PesepayService(
    config('pesepay.integration_key'),
    config('pesepay.encryption_key'),
    config('pesepay.return_url'),
    config('pesepay.result_url')
);

Ecocash Payment

try {
    $payment = $pesepay->ecocash([
        'amount'        => 10.50,
        'phone'         => '263771234567',
        'email'         => 'customer@example.com',
        'reference'     => 'PZW211',                // Dont change the reference code 
        'description'   => 'Product purchase'
    ]);
    
    // Store $payment['reference_number'] and $payment['poll_url'] in your database
} catch (\Chitanga\Pesepay\Exceptions\PesepayException $e) {
    // Handle payment error
}

Card Payment

try {
    $payment = $pesepay->card([
        'amount'        => 25.00,
        'email'         => 'customer@example.com',
        'card_number'   => '4111111111111111',
        'card_expiry'   => '12/25',
        'card_cvv'      => '123',
        'reference'     => 'PWZ204'                 // Dont change the reference code 
    ]);
    
    // Process payment response
} catch (\Chitanga\Pesepay\Exceptions\PesepayException $e) {
    // Handle payment error
}

Check Payment Status

// Using the poll_url from the payment response
$status = $pesepay->checkPaymentStatus($pollUrl);

if ($status['success']) {
    // Payment was successful
} else {
    // Payment failed or is pending
}

// Quick check
if ($pesepay->isPaymentSuccessful($pollUrl)) {
    // Payment successful
}

Error Handling

The package throws PesepayException for all payment-related errors. You can catch and handle these exceptions:

try {
    // Payment operations
} catch (\Chitanga\Pesepay\Exceptions\PesepayException $e) {
    // Get error details
    $errorMessage = $e->getMessage();
    $errorCode = $e->getCode();
    $errorData = $e->getData();
    
    // Handle error appropriately
}

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-09