hydrogenafrica/hydrogenpay-ci4 问题修复 & 功能扩展

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

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

hydrogenafrica/hydrogenpay-ci4

Composer 安装命令:

composer require hydrogenafrica/hydrogenpay-ci4

包简介

Hydrogenpay SDK integration for CodeIgniter 4 applications

README 文档

README

Hydrogenpay PHP SDK for CodeIgniter 4 makes it easy to connect your apps to the Hydrogenpay APIs.
It simplifies integration, so you can quickly collect payments, handle payouts, and more — all in just a few lines of code.

Features

Operation Description
Single Payment Create a one-time payment request using either card or bank transfer.
Recurring Payment Set up a subscription-based payment request for card payments.
Cancel Recurring Cancel a recurring transaction or deactivate a card token associated with a recurring payment.
Simulate Transfer To test the bank transfer functionality during the development phase of integrating the Payment Gateway.
Initiate Transfer Generate unique account details to receive transfer-only payment requests.
Payment Confirmation Confirm and validate the status of a completed card or transfer payment.
Payment Webhook The webhook allows you to receive instant notifications about payment status from the payment gateway.

Table of Contents

  1. Requirements
  2. Installation
  3. Usage
  4. Contributing
  5. License
  6. API References

Requirements

Installation

Install via Composer:

composer require hydrogenafrica/hydrogenpay-ci4

Then copy the provided .env.example file to .env and update with your Hydrogenpay credentials:

cp .env.example .env

Example .env settings:

LIVE_API_KEY=SK_LIVE_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
SANDBOX_KEY=PK_TEST_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
MODE=TEST
  • LIVE_API_KEY: Your HydrogenPay live API key obtained from the dashboard. (Required)
  • SANDBOX_KEY: Your HydrogenPay sandbox API key obtained from the dashboard. (Required)
  • MODE: Defines the environment mode. Set to LIVE to use the LIVE_API_KEY or TEST to use the SANDBOX_KEY. (Required)

Usage

Single Payment

Create a one-time payment request using either card or bank transfer.

First, import the class:

use HydrogenAfrica\HydrogenpayCi4\Hydrogenpay\CollectPayment;

Then initiate a payment:

 $data = [
            'amount'          => 50,
            'customer_name'   => 'Dev Test',
            'customer_email'  => 'devtest@randomuser.com',
            'currency'        => 'NGN',
            'description'     => 'test desc',
            'meta'            => 'test meta',
            'callback'        => base_url('verify'), // must match your app's route
        ];

        # return CollectPayment::standard($data); 
        $result = CollectPayment::recurring($data); // get JSON string
        $decoded = json_decode($result);

        echo "\n==== Raw decoded response ====\n";
        var_dump($decoded);

Recurring Payment

Set up a subscription-based payment request for card payments.

First, import the class:

use HydrogenAfrica\HydrogenpayCi4\Hydrogenpay\CollectPayment;
$data = [
            'amount'          => 50,
            'customer_name'   => 'Dev Test',
            'customer_email'  => 'devtest@randomuser.com',
            'currency'        => 'NGN',
            'description'     => 'Weekly subscription',
            'meta'            => 'subscription_id:5678',
            'callback'        => base_url('verify'), // must match your app's route
            'frequency'       => 1,
            'is_recurring'    => true,
            'end_date'        => '2025-08-14T23:59:59Z',
        ];


        return CollectPayment::recurring($data);

Cancel Recurring

Cancel a recurring transaction or deactivate a card token associated with a recurring payment.

First, import the class:

use HydrogenAfrica\HydrogenpayCi4\Hydrogenpay\CollectPayment;
        $transactionRef = '36934683_76927e4cf6'; // Replace this with a real transactionRef

        if (empty($transactionRef)) {
            $this->fail('transactionRef is empty. Please replace with a real transactionRef to test cancelRecurring.');
        }

        $result = CollectPayment::cancelRecurring([
            'transactionRef' => $transactionRef,
            'token' => '2c382ed1-b5e5-4050-81fb-1b4d61443429',
        ]);

        $decoded = json_decode($result);

        echo "\n==== Cancel Recurring Response ====\n";
        var_dump($decoded);

Initiate Transfer

Generate unique account details to receive transfer-only payment requests.

First, import the class:

use HydrogenAfrica\HydrogenpayCi4\Hydrogenpay\CollectPayment;
        $data = [
            'amount'         => 50,
            'customer_name'  => 'Dev Test',
            'email'          => 'devtest@randomuser.com',
            'currency'       => 'NGN',
            'description'    => 'Bank transfer test',
            'meta'           => 'order_id:1234',
            'callback'       => base_url('verify'),
        ];

        $result = CollectPayment::bankTransfer($data);
        $decoded = json_decode($result);

        echo "\n==== Bank Transfer Response ====\n";
        var_dump($decoded);

Simulate Transfer

To test the bank transfer functionality during the development phase of integrating the Payment Gateway. Developers are required to select the bank transfer method at the payment checkout stage before making the request

First, import the class:

use HydrogenAfrica\HydrogenpayCi4\Hydrogenpay\CollectPayment;
         $data = [
            'clientTransactionRef' => '36934683_774526591e', // A unique trax ref for the client’s transaction
            'currency'             => 'NGN',
            'amount'               => 50,
        ];

        $result = CollectPayment::simulateBankTransfer($data);
        $decoded = json_decode($result);

        echo "\n==== Raw decoded response ====\n";
        var_dump($decoded);

Payment Confirmation

Confirm and validate the status of a completed card or transfer payment.

First, import the class:

use HydrogenAfrica\HydrogenpayCi4\Hydrogenpay\CollectPayment;
   
        $transactionRef = '36934683_76927e4cf6'; // Replace with a real transaction ref

        try {
            $verification = Verification::transaction($transactionRef);

            // Dump some fields so you can see
            echo "\nVerified Transaction Ref: " . $verification->transactionRef() . "\n";
            echo "Status: " . $verification->status() . "\n";
            echo "Amount: " . $verification->amount() . "\n";

        } catch (Exception $e) {
            // Fail the test with the exception message
            $this->fail('Verification failed: ' . $e->getMessage());
        }

Payment Webhook

The webhook allows you to receive instant notifications about payment status from the payment gateway.

First, import the class:

use HydrogenAfrica\HydrogenpayCi4\Hydrogenpay\CollectPayment;
   
   //Verify Webhook
if (Webhook::verifyWebhook())
   {
      // Continue reading the webhook data
      Webhook::data()->status();

   }

API References

Contributing

Feel free to add more test cases, edge scenarios, or submit improvements! Pull requests are welcome.

License

© HydrogenPay – All rights reserved.

hydrogenafrica/hydrogenpay-ci4 适用场景与选型建议

hydrogenafrica/hydrogenpay-ci4 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 hydrogenafrica/hydrogenpay-ci4 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-16