PHPackages                             masoodrehman/php-payment-gateway-hbl - 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. [API Development](/categories/api)
4. /
5. masoodrehman/php-payment-gateway-hbl

ActiveLibrary[API Development](/categories/api)

masoodrehman/php-payment-gateway-hbl
====================================

Payment gateway for Habib Bank Limited (HBL).

v1.0(5y ago)8185[1 issues](https://github.com/MasoodRehman/php-payment-gateway-hbl/issues)MITPHP

Since Feb 23Pushed 2y ago2 watchersCompare

[ Source](https://github.com/MasoodRehman/php-payment-gateway-hbl)[ Packagist](https://packagist.org/packages/masoodrehman/php-payment-gateway-hbl)[ RSS](/packages/masoodrehman-php-payment-gateway-hbl/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)DependenciesVersions (2)Used By (0)

PHP client for the HBL payment gateway.
=======================================

[](#php-client-for-the-hbl-payment-gateway)

This client library provides access to the payment gateway web service interface of Habib Bank Limited (HBL) Pakistan.

To use this client, you must first obtain your personal access to the Web Service interface from HBL.

Requirements
============

[](#requirements)

- PHP 5.4 or newer *(tested with 5.4 -&gt; 7.2)*
- CURL, JSON and OpenSSL extensions activated
- A authentication details from HBL

Installation
============

[](#installation)

The preferred method of installation is via [Composer](https://getcomposer.org/). Run the following command to install the package and add it as a requirement to your project's composer.json:

```
composer require masoodrehman/php-payment-gateway-hbl

```

Example
=======

[](#example)

To create an HBL client

```
$hblPay = new Client([
    "env" => Constant::ENV_SANDBOX,
    "authentication" => new AuthenticationFields([
        "USER_ID" => "user-id",
        "PASSWORD" => "password",
        "CHANNEL" => "channel-name",
        "RETURN_URL" => "http://localhost:8001/example/success.php", // replace with your own
        "CANCEL_URL" => "http://localhost:8001/example/fail.php" // replace with your own
    ]),
    "rsa" => [
        "publicKeyPath" => "",
        "privateKeyPath" => "",
    ]
]);
```

A basic example with minimum required parameters in request payload.

```
    use HBLPay\Client;
    use HBLPay\Common\Constant;
    use HBLPay\Model\AdditionalData;
    use HBLPay\Model\AuthenticationFields;
    use HBLPay\Model\CheckoutReq;
    use HBLPay\Model\Item;
    use HBLPay\Model\Order;
    use HBLPay\Model\ShippingDetail;

    try
    {
        // Request construction. Given the minimum required data.
        $checkoutReq = new CheckoutReq([
            "ORDER" => new Order([
                "DISCOUNT_ON_TOTAL" => 0, // Required - (In doc mentioned Optional)
                "SUBTOTAL" => 100, // Required
                "OrderSummaryDescription" => [
                    new Item([
                        "ITEM_NAME" => "item name",
                        "CATEGORY" => "category name",
                        "SUB_CATEGORY" => "item sub category name",
                        "UNIT_PRICE" => 100,
                        "QUANTITY" => 1
                    ])
                ] // Required
            ]),
            "SHIPPING_DETAIL" => new ShippingDetail([
                "NAME" => "NULL", // Required
            ]),
            "ADDITIONAL_DATA" => new AdditionalData([
                "REFERENCE_NUMBER" => sprintf("INVOICE%s", time()), // Required
                "CUSTOMER_ID" => "1", // Required - (Did not mention in document)
                "CURRENCY" => "PKR", // Required
                "BILL_TO_FORENAME" => "First name", // Required
                "BILL_TO_SURNAME" => "Last name", // Required
                "BILL_TO_EMAIL" => "youremail@gmail.com", // Required
                "BILL_TO_PHONE" => "+921112222222", // Required
                "BILL_TO_ADDRESS_LINE" => "Street address", // Required
                "BILL_TO_ADDRESS_CITY" => "City", // Required
                "BILL_TO_ADDRESS_STATE" => "State", // Required
                "BILL_TO_ADDRESS_COUNTRY" => "PK", // Required
                "BILL_TO_ADDRESS_POSTAL_CODE" => "00000", // Required
            ])
        ]);

        // Call service
        $hblPay->getSessionAndRedirectToPortal($checkoutReq);
    }
    catch (Exception $e)
    {
        echo $e->getMessage();
    }
```

API Summary
-----------

[](#api-summary)

MethodDescriptiongetSessionId(CheckoutReq $checkoutReq)Get session id from HBLredirectToPortal(string $sessionId)Take session id as parameter and redirect to HBL portalgetSessionAndRedirectToPortal(CheckoutReq $checkoutReq)This method do both work in single request, Get session from HBL and redirect to HBL portal for payment.### Public Key

[](#public-key)

HBL required RSA 4096-bit key which they use for data encryption in order to secure the request payload over network layer. Generate your key's and add path during client initialization.

You would need following keys:

- hbl-public.pem (public key shared by HBL)
- pub.pem (Your public key shared with HBL)
- key.pem (Your private key)

### Test Cards:

[](#test-cards)

```
VISA (Non 3D card)
Card #:             4000000000000101
CVV:                111
Expiry:             12/2020

VISA (3D card)
Card #:             4000000000000002
CVV:                111
Expiry:             12/2020
Test Password:      1234

---------------------------------------

MASTER (Non 3D card)
Card #:             5200000000000114
CVV:                111
Expiry:             12/2020

MASTER (3D card)
Card #:             5200000000000007
CVV:                111
Expiry:             12/2020
Test Password:      1234

```

For more detail check the official documentation [here](docs/HBLPay-Integration-Guide-V1.1.pdf).

***Note: The official documentation is not upto date and has some inconsistency.***

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1956d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b96315cb4efc4b3535c60354e85df9067b1924b9ad80af6e71d13f46a9ddc5e0?d=identicon)[MasoodRehman](/maintainers/MasoodRehman)

---

Top Contributors

[![MasoodRehman](https://avatars.githubusercontent.com/u/14925163?v=4)](https://github.com/MasoodRehman "MasoodRehman (1 commits)")

---

Tags

apigatewayhblpakistanpaymentpayment-gatewayphp

### Embed Badge

![Health badge](/badges/masoodrehman-php-payment-gateway-hbl/health.svg)

```
[![Health](https://phpackages.com/badges/masoodrehman-php-payment-gateway-hbl/health.svg)](https://phpackages.com/packages/masoodrehman-php-payment-gateway-hbl)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
