PHPackages                             hydrogenpay/hydrogenpay-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. hydrogenpay/hydrogenpay-sdk

ActiveLibrary[Payment Processing](/categories/payments)

hydrogenpay/hydrogenpay-sdk
===========================

A straightforward SDK for seamlessly integrating Hydrogenpay Payment Gateway into your PHP applications, including popular PHP frameworks such as Laravel, Symfony and Codeigniter

012PHP

Since Sep 4Pushed 1y agoCompare

[ Source](https://github.com/HydrogenAfrica/php-sdk)[ Packagist](https://packagist.org/packages/hydrogenpay/hydrogenpay-sdk)[ RSS](/packages/hydrogenpay-hydrogenpay-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

**Integrating Hydrogen PHP SDK Library for easy access to Hydrogen APIs**
=========================================================================

[](#integrating-hydrogen-php-sdk-library-for-easy-access-to-hydrogen-apis)

**Hydrogen Payment Gateway helps you process payments using cards and account transfers for faster delivery of goods and services on your PHP site.**
**It abstracts the complexity involved in direct integration and allows you to make quick calls to the APIs.**

**This SDK communicates with Hydrogen API. You need to have a Hydrogen merchant account and Auth Key to use this SDK.**

**Requirements**
================

[](#requirements)

- **Composer**
- **An IDE**
- **Hydrogen Auth Token**
- **Acceptable PHP versions: &gt;= 7.4.0. for older versions of PHP**

**Sign up account here:** [**https://dashboard.hydrogenpay.com/signup**](https://dashboard.hydrogenpay.com/signup)

**Installation**
=================

[](#installation)

**To get started, First you need to install the package into your existing project.**

**To install the package via Composer, run the following command.**

```

composer require hydrogenpay/hydrogenpay-sdk:@dev

```

**Alternatively, you can add the package to your composer.json file and run the command composer install on your editor terminal.**

```
{
    "require": {

        "hydrogenpay/hydrogenpay-sdk": "@dev"

    }
}

```

**This command installs the package. The package can be found in the vendor folder.****if you get an error message while running the command, ensure you have composer installed.**

**Initialization**
===================

[](#initialization)

**After installation, create a .env file in the root of the project. Most frameworks (such as Laravel and Symfony support the use of .env files). if you are not using a framework you need to create one.**

**Create a .env file and follow the format of the .env.example file.Save your, SANDBOX, LIVE\_API\_KEY, MODE in the .env fileYour .env file should look like the below:**

```
SANDBOX=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

LIVE_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

MODE=test

# MODE=live // test mode for payment testing and live mode is for production
```

**The SDK provides two easy methods of making collections via the Payment Gateway modal.**

- **REDIRECT**
- **POPUP**

```
try {
    HydrogenpayAfrica::bootstrap();

    $customHandler = new PaymentHandler();

    $client = new HydrogenpayAfrica();

    $modalType = Modal::REDIRECT; // Modal::POPUP or Modal::REDIRECT

    $controller = new TransactionController( $client, $customHandler, $modalType );

} catch(\Exception $e ) {

    echo $e->getMessage();

}
```

**Edit the processTransaction.php files to suite your purpose by either changing the Modal to POPUP or REDIRECT.**

**Transaction Resources**
==========================

[](#transaction-resources)

**Edit the transactionForm.php and processTransaction.php files to suit your purpose. Both files are well documented.**

**Simply redirect to the transactionForm.php file on your browser to process a payment.**

**In this implementation, we are expecting a form-encoded POST request.The request will contain the following parameters. Request parameters**

Request Parameters
==================

[](#request-parameters)

MandatoryNameCommentYesamountThe amount to be charged for the transaction.YesemailThe customer's email address.YescurrencyThe currency in which the transaction is processed.NodescriptionA brief description of the transaction.NometaAdditional metadata or information related to the transaction.YescallbackCallback redirection```
{
    "amount": "The amount to be charged for the transaction",
    "customerName": "Dev Test",
    "email": "devtest@randomuser.com",
    "currency": "NGN",
    "description": "test desc",
    "meta": "test meta",
    "callback": "https://docs.hydrogenpay.com/reference/payment-gateway",
  }
```

**The script in processTransaction.php handles the request data via the TransactionController. If you are using a Framework like Laravel or CodeIgniter you might want to take a look at the TransactionController.**

```
