kennedymbale/zynle-pay-php-sdk 问题修复 & 功能扩展

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

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

kennedymbale/zynle-pay-php-sdk

Composer 安装命令:

composer require kennedymbale/zynle-pay-php-sdk

包简介

Professional PHP SDK for ZynlePay payment gateway API supporting Mobile Money and Card payments in Zambia.

README 文档

README

A comprehensive PHP 8+ SDK for integrating with the ZynlePay payment gateway API. Supports both production and sandbox environments with full type safety and comprehensive error handling.

Features

  • PHP 8.0+ with strict typing
  • Production & Sandbox environment support
  • Type-safe API with detailed PHPDoc
  • Comprehensive error handling with custom exceptions
  • Input validation for all methods
  • Composer-ready package structure
  • Full test coverage with PHPUnit

Installation

Install via Composer:

composer require kennedymbale/zynle-pay-php-sdk

Quick Start

use ZynlePay\Client;
use ZynlePay\MomoDeposit;

// Initialize client for sandbox
$client = new Client(
    merchantId: 'your_merchant_id',
    apiId: 'your_api_id',
    apiKey: 'your_api_key',
    channel: 'momo',
    serviceId: '1002'
);

// Create service instance
$momoDeposit = new MomoDeposit($client);

// Process a payment
try {
    $result = $momoDeposit->runBillPayment(
        senderId: '09XXXXXXXX',
        referenceNo: uniqid('ref_', true),
        amount: 1000.00,
        description: 'Payment for services'
    );

    echo "Payment initiated: " . $result['transaction_id'];
} catch (ZynlePay\Exception\ApiException $e) {
    echo "Payment failed: " . $e->getMessage();
}

Configuration

Client Class

$client = new Client(
    string $merchantId,      // Your ZynlePay merchant ID
    string $apiId,          // Your API ID
    string $apiKey,         // Your API key
    string $channel,        // Payment channel (momo, card, bank, etc.)
    string $serviceId = '1002',  // Service ID (default: '1002')
    bool $sandbox = true     // true for sandbox, false for production
);

Services

MomoDeposit - MOMO Mobile Money Payments

Process MOMO mobile money payments and check payment status.

use ZynlePay\MomoDeposit;

$momoDeposit = new MomoDeposit($client);

// Process payment
$result = $momoDeposit->runBillPayment(
    senderId: '09XXXXXXXX',               // Sender's phone number
    referenceNo: uniqid('ref_', true),     // Unique reference number
    amount: 1000.00,                        // Amount in float
    description: 'Payment'                   // Optional description
);

// Check payment status
$status = $momoDeposit->checkPaymentStatus('REF123456');

CardDeposit - Credit/Debit Card Processing

Handle credit and debit card payments with full PCI compliance.

use ZynlePay\MomoDeposit;
$momoService = new MomoDeposit($client);

try {
    $result = $momoService->runBillPayment(
        senderId: '09XXXXXXXX',
        referenceNo: uniqid('ref_', true),
        amount: 70,
        description: 'Payment for services'
    );

    echo "<h3>".$result['response_description']."</h3>";
    echo "<p>Transaction ID: " . $result['transaction_id'] . "</p>";
    echo "<p>Operator: " . $result['operator'] . "</p>";
    echo "<p>transaction_date: " . $result['transaction_date'] . "</p>";

} catch (ZynlePay\Exception\ApiException $e) {
    echo "Payment failed: " . $e->getMessage();
}

WalletToBank - Bank Transfers from Wallet

Transfer funds from your wallet to bank accounts.

use ZynlePay\WalletToBank;

$walletToBank = new WalletToBank($client);

// Transfer to bank
$result = $walletToBank->runPayToBank(
    referenceNo: uniqid('ref_', true),
    amount: 500.00,
    description: 'Bank transfer',
    bankName: 'Bank of Example',
    receiverId: '1234567890'
);

// Check transfer status
$status = $walletToBank->checkBankTransferStatus('REF123456');

MomoWithdraw - E-wallet Withdrawals

Withdraw funds to MOMO mobile money accounts.

use ZynlePay\MomoWithdraw;

$momoWithdraw = new MomoWithdraw($client);

// Withdraw to MOMO
$result = $momoWithdraw->runPayToEwallet(
    referenceNo: 'REF123456',
    amount: 200.00,
    receiverId: '09XXXXXXXX'
);

// Check withdrawal status
$status = $momoWithdraw->checkEwalletTransferStatus('REF123456');

PaymentStatus - Payment Status Checking

Check the status of any payment transaction.

use ZynlePay\PaymentStatus;

$paymentStatus = new PaymentStatus($client);

// Check payment status
try {
    $status = $paymentStatus->checkStatus('REF123456');
    echo "Payment status: " . $status['status'];
} catch (ZynlePay\Exception\ApiException $e) {
    echo "Status check failed: " . $e->getMessage();
}

CheckBalance - Account Balance Inquiry

Check your account balance and available funds.

use ZynlePay\CheckBalance;

$checkBalance = new CheckBalance($client);

// Check account balance
try {
    $balance = $checkBalance->checkBalance();
    echo "Current balance: " . $balance['balance'] . " " . $balance['currency'];
} catch (ZynlePay\Exception\ApiException $e) {
    echo "Balance check failed: " . $e->getMessage();
}

WebhookHandler - Webhook Processing

Handle payment confirmation webhooks from ZynlePay.

use ZynlePay\WebhookHandler;

$webhookHandler = new WebhookHandler();

// Process webhook data
try {
    $result = $webhookHandler->handle($_POST);
    echo "Webhook processed: " . $result['status'];
} catch (ZynlePay\Exception\ApiException $e) {
    echo "Webhook processing failed: " . $e->getMessage();
}

Error Handling

All service methods throw ZynlePay\Exception\ApiException for API-related errors:

try {
    $result = $momoDeposit->runBillPayment('09XXXXXXXX', 'REF123', 100.00);
} catch (ZynlePay\Exception\ApiException $e) {
    // Handle API errors (invalid credentials, network issues, etc.)
    error_log("API Error: " . $e->getMessage());
    error_log("Error Code: " . $e->getCode());
} catch (InvalidArgumentException $e) {
    // Handle validation errors (invalid amount, etc.)
    error_log("Validation Error: " . $e->getMessage());
}

API Reference

Client Class

  • __construct(string $merchantId, string $apiId, string $apiKey, string $channel, string $serviceId = '1002', ?bool $sandbox = null)

MomoDeposit Methods

  • runBillPayment(string $senderId, string $referenceNo, float $amount, string $description = 'Payment'): array
  • checkPaymentStatus(string $referenceNo): array

CardDeposit Methods

  • runTranAuthCapture(string $referenceNo, float $amount, string $cardNumber, string $expiryMonth, string $expiryYear, string $cvv, ...$optional): array

WalletToBank Methods

  • runPayToBank(string $referenceNo, float $amount, string $description = 'Bank Transfer', string $bankName = '', string $receiverId = '', ?string $callbackUrl = null, ?string $successUrl = null, ?string $failUrl = null): array
  • checkBankTransferStatus(string $referenceNo): array

MomoWithdraw Methods

  • runPayToEwallet(string $referenceNo, float $amount, string $receiverId): array
  • checkEwalletTransferStatus(string $referenceNo): array

PaymentStatus Methods

  • checkPaymentStatus(string $referenceNo): array

CheckBalance Methods

  • checkBalance(): array

WebhookHandler Methods

  • handle(array $webhookData): array

Testing

Run the test suite with PHPUnit:

composer test

Run specific test files:

./vendor/bin/phpunit tests/MomoDepositTest.php

Requirements

  • PHP: 8.0 or higher
  • Extensions: curl, json
  • Composer: For dependency management
  • PHPUnit: For testing (development only)

Support

For issues and questions:

  • Check the ZynlePay API Documentation (sign in to access)
  • Review the test files for usage examples
  • Ensure your credentials and configuration are correct

License

This SDK is released under the MIT License. See LICENSE file for details.

kennedymbale/zynle-pay-php-sdk 适用场景与选型建议

kennedymbale/zynle-pay-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「payment」 「sdk」 「gateway」 「card」 「mobile money」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kennedymbale/zynle-pay-php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kennedymbale/zynle-pay-php-sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 kennedymbale/zynle-pay-php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-02