承接 bixi/client 相关项目开发

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

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

bixi/client

最新稳定版本:2.0.0

Composer 安装命令:

composer require bixi/client

包简介

A PHP client for Bixi payment processor.

README 文档

README

Main Dev Coverage Version
Main Main Coverage Version

This package provides a small client for interacting with the Bixi API to process payments and receive responses.

Features

  • Simple and intuitive client setup.
  • Comprehensive test coverage using Pest.

Requirements

  • PHP 8.3 or higher
  • Composer
  • GuzzleHTTP
  • Pest (for testing)

Installation

Install the package via Composer:

composer require bixi/client

Getting Started

Step 1: Initialize the Client

use Bixi\Client\Bixi;

$apiToken = 'Your-API-Token';
$bixi = new Bixi($apiToken);

Step 2: Making a Payment Request

try {
    $response = $bixi->pay([
        'memo' => 'credit',
        'accountNumber' => '+252600000000',
        'accountType' => 'mmt',
        'receiptId' => '123456',
        'amount' => 1.00,
        'description' => 'Payment for invoice No. 123456',
    ]);

    echo "Transaction Successful! Transaction ID: " . $response->getId() . PHP_EOL;
    print_r($response->toArray());
} catch (ClientException $e) {
    echo "Error: {$e->getMessage()}" . PHP_EOL;
    print_r($e->getErrors());
}

Step 3: Handling Responses

You can access different parts of the response using methods like getId(), getAttributes(), and getAttribute():

$data = $response->toArray(); // Convert response to an array
$id = $response->getId(); // Transaction ID
$attributes = $response->getAttributes(); // All attributes
$amount = $response->getAttribute('amount'); // Specific attribute

Step 4: Handling Exceptions

When an error occurs, a ClientException will be thrown with detailed error messages:

catch (ClientException $e) {
    foreach ($e->getErrors() as $error) {
        echo "Error Code: {$error['code']} - {$error['detail']}" . PHP_EOL;
    }
}

Testing

This package includes comprehensive test coverage using the Pest PHP testing framework. To run the tests, use the following command:

./vendor/bin/pest

License

This package is licensed under the MIT license. Please see the LICENSE file for more information.

Contributing

Contributions are welcome! Please feel free to open issues or submit pull requests.

Changelog

For the complete list of changes, please see the changelog file.

Contact

For support or inquiries, please contact the package maintainer at hi@bixi.so.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-27