定制 fapshi/payments 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

fapshi/payments

最新稳定版本:v1.0.0

Composer 安装命令:

composer require fapshi/payments

包简介

PHP client for Fapshi Payments API (sandbox/live)

README 文档

README

PHP SDK for the Fapshi Payments API. Supports sandbox and live environments.

Installation

composer require fapshi/payments

Quick start

<?php
require __DIR__ . '/vendor/autoload.php';

use Fapshi\Client;

$client = new Client('your_api_user', 'your_api_key');

// Create a payment link
$link = $client->initiatePay([
    'amount' => 1500,
    'email' => 'user@example.com',
    'redirectUrl' => 'https://yourapp.com/payment/return',
]);

// Direct pay to phone
$direct = $client->directPay([
    'amount' => 1500,
    'phone' => '677000000',
    'medium' => 'mobile money',
]);

// Check payment status
$status = $client->getPaymentStatus($link['transId']);

// Expire a payment
$expired = $client->expirePay($link['transId']);

// Get user transactions
$userTx = $client->getTransactionsByUserId('user-123');

// Search transactions
$search = $client->searchTransactions([
    'status' => 'successful',
    'limit' => 10,
]);

// Get balance
$balance = $client->getBalance();

// Payout
$payout = $client->payout([
    'amount' => 2000,
    'phone' => '677000000',
    'medium' => 'mobile money',
]);

Environments

  • Auto-detected from apikey when environment is not passed:
    • FAK_TEST_... → sandbox (https://sandbox.fapshi.com)
    • FAK_... → live (https://live.fapshi.com)
  • You can force with helpers: Client::sandbox(...) or Client::live(...), or pass the env name as the 3rd constructor arg. Passing a baseUrlOverride to the constructor also disables detection.

Auth headers are automatically set from constructor: apiuser, apikey.

API coverage

  • POST /initiate-pay
  • POST /direct-pay
  • GET /payment-status/{transId}
  • POST /expire-pay
  • GET /transaction/{userId}
  • GET /search
  • GET /balance
  • POST /payout

Error handling

All non-2xx responses throw Fapshi\Exceptions\FapshiException with:

  • getMessage() → API message or generic status text
  • getStatusCode() → HTTP status code
  • getResponseBody() → decoded JSON body (array) when available

Development

  • PHP >= 8.0
  • GuzzleHTTP ^7.9 or ^8

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-30