santosdave/pesawise-wrapper 问题修复 & 功能扩展

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

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

santosdave/pesawise-wrapper

最新稳定版本:v1.3.1

Composer 安装命令:

composer require santosdave/pesawise-wrapper

包简介

A Laravel package for integrating Pesawise payment gateway

README 文档

README

A Laravel package for integrating the Pesawise payment gateway into your application.

Installation

You can install the package via composer:

composer require santosdave/pesawise-wrapper

Configuration

After installation, publish the config file:

php artisan vendor:publish --provider="Santosdave\PesawiseWrapper\PesawiseProvider"

This will create a config/pesawise.php file. Update your .env file with your Pesawise credentials:

PESAWISE_API_KEY=your_api_key
PESAWISE_API_SECRET=your_api_secret
PESAWISE_ENVIRONMENT=sandbox
PESAWISE_DEBUG=false
PESAWISE_DEFAULT_CURRENCY=KES
PESAWISE_DEFAULT_BALANCE_ID=your_default_balance_id

Usage

You can use the Pesawise facade or inject the Pesawise class into your controllers/services.

use Santosdave\PesawiseWrapper\Facades\Pesawise;

// Or inject in your constructor
use Santosdave\PesawiseWrapper\Pesawise;

public function __construct(Pesawise $pesawise)
{
    $this->pesawise = $pesawise;
}

Using Dependency Injection

use Santosdave\PesawiseWrapper\Pesawise;

class PaymentService
{
    protected $pesawise;

    public function __construct(Pesawise $pesawise)
    {
        $this->pesawise = $pesawise;
    }

    public function processPayment(array $paymentData)
    {
        return $this->pesawise->createDirectPayment($paymentData);
    }
}

Available Methods

Get All Supported Banks

$banks = Pesawise::getAllSupportedBanks();

Validate Bank Recipient

use Santosdave\PesawiseWrapper\Requests\BankRecipientValidationRequest;

$request = new BankRecipientValidationRequest(
    bankId: 1,
    bankAccountNumber: '1234567890'
);

$recipient = Pesawise::validateBankRecipient($request);

Create Bulk Payment

use Santosdave\PesawiseWrapper\Requests\BulkPaymentRequest;
use Santosdave\PesawiseWrapper\DataTypes\Currency;
use Santosdave\PesawiseWrapper\DataTypes\BulkPayment;
use Santosdave\PesawiseWrapper\DataTypes\TransferType;

$bulkPayments = [
    new BulkPayment(
        amount: 1000,
        transferType: new TransferType(TransferType::BANK),
        reference: 'REF123',
        recipient: 'John Doe',
        bankId: 1,
        accountNumber: '1234567890'
    )
];

$request = new BulkPaymentRequest(
    balanceId: 1001002,
    currency: new Currency(Currency::KES),
    bulkPayments: $bulkPayments
);

$bulkPayment = Pesawise::createBulkPayment($request);

Create Payment Order

$order = Pesawise::createPaymentOrder([
    'amount' => 1000,
    'customerName' => 'John Doe',
    'currency' => 'KES',
    'externalId' => 'ORDER123',
    'description' => 'Product purchase',
    'balanceId' => 1001002,
    'callbackUrl' => 'https://example.com/callback'
]);

Complete Payment

use Santosdave\PesawiseWrapper\Requests\CompletePaymentRequest;

$request = new CompletePaymentRequest(
    paymentId: 'payment_id_here',
    otp: '123456'
);

$payment = Pesawise::completePayment($request);

Create Direct Payment

$payment = Pesawise::createDirectPayment([
    'balanceId' => 1001002,
    'currency' => 'KES',
    'amount' => 1000,
    'transferType' => 'BANK',
    'reference' => 'REF123',
    'recipient' => 'John Doe',
    'bankId' => 1,
    'accountNumber' => '1234567890'
]);

For more methods and detailed usage, refer to the Pesawise API documentation.

Error Handling

The package throws PesawiseException for API errors. You can catch and handle these exceptions in your application:

use Santosdave\PesawiseWrapper\Exceptions\PesawiseException;

try {
    $payment = Pesawise::createDirectPayment([...]);
} catch (PesawiseException $e) {
    $errorMessage = $e->getMessage();
    $errorCode = $e->getCode();
    $errorResponse = $e->getErrorResponse();
    // Handle the error
}

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email the author instead of using the issue tracker.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固