PHPackages                             himosoft/payments - 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. himosoft/payments

ActiveLibrary[Payment Processing](/categories/payments)

himosoft/payments
=================

The official PHP SDK for integrating HimoSoft Payments gateway

00PHP

Since May 27Pushed 1mo agoCompare

[ Source](https://github.com/Swe-HimelRana/himosoft-payments-php)[ Packagist](https://packagist.org/packages/himosoft/payments)[ RSS](/packages/himosoft-payments/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

🐘 HimoSoft Payments SDK for PHP
===============================

[](#-himosoft-payments-sdk-for-php)

Welcome to the official **HimoSoft Payments SDK** for PHP. This library allows PHP developers to quickly and securely integrate HimoSoft's payment gateway into any modern PHP application—fully compatible with **Laravel**, **Symfony**, **Yii**, **WordPress**, or standalone PHP scripts.

---

⚡ Key Features
--------------

[](#-key-features)

- **🛡️ Secure HMAC-SHA256 Signatures**: Sealing payload strings using exact hash matches.
- **🕒 Replay Attack Protection**: Embedded timestamp validity checks on every request.
- **📋 Metadata Schema Verification**: Ensures all required merchant tracking attributes are validated client-side.
- **🧩 Zero-Dependency Native cURL**: Runs on standard PHP `curl` extension (compatible with PHP &gt;= 7.0), avoiding version conflicts with libraries like Guzzle.
- **🌐 Mathematical URL Calibration**: Uses `JSON_UNESCAPED_SLASHES` to align signature encodings perfectly with the server-side Python parser.

---

📦 Installation
--------------

[](#-installation)

### Composer Installation (Recommended)

[](#composer-installation-recommended)

You can include this package in your project via Composer. Add this to your `composer.json`:

```
"repositories": [
    {
        "type": "path",
        "url": "./integration-package/php"
    }
],
"require": {
    "himosoft/payments": "^1.0"
}
```

Then run:

```
composer install
```

### Manual Autoload Fallback (No-Composer / WordPress)

[](#manual-autoload-fallback-no-composer--wordpress)

If you are working in an environment without Composer, you can manually load the files by copying the `src/` folder to your project and registering a simple autoloader:

```
spl_autoload_register(function ($class) {
    $prefix = 'HimoSoft\\Payments\\';
    $base_dir = __DIR__ . '/src/'; // Point this to your copied src/ directory

    $len = strlen($prefix);
    if (strncmp($prefix, $class, $len) !== 0) {
        return;
    }

    $relative_class = substr($class, $len);
    $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
    if (file_exists($file)) {
        require $file;
    }
});
```

---

🚀 Quickstart Guides
-------------------

[](#-quickstart-guides)

The PHP SDK supports both **Synchronous** calls (standard workflows) and **Asynchronous Batch** calls (for high-speed concurrent processing with zero dependencies).

### 1. Synchronous Quickstart (Laravel, Symfony, WordPress)

[](#1-synchronous-quickstart-laravel-symfony-wordpress)

Creating a payment and retrieving its status in a standard PHP blocking request:

```
use HimoSoft\Payments\HimoSoftPaymentsClient;
use HimoSoft\Payments\Exceptions\HimoSoftException;

$client = new HimoSoftPaymentsClient("your_api_key", "your_api_secret", "https://pay.himosoft.com.bd");

try {
    $payment = $client->createPayment([
        "amount" => "500.00",
        "currency" => "BDT",
        "reference_id" => "INV-99081",
        "description" => "Cloud Hosting Subscription",
        "redirect_url" => "https://yourwebsite.com/success",

        // Required Customer Metadata
        "customer_id" => "CUST-44321",
        "customer_email" => "jane.doe@example.com",
        "customer_name" => "Jane Doe",

        // Required Product Metadata
        "product_name" => "Professional Shared Hosting",
        "product_price" => "500.00",
        "product_quantity" => 1
    ]);

    echo "Checkout URL: " . $payment['checkout_url'] . "\n";
} catch (HimoSoftException $e) {
    echo "SDK Error: " . $e->getMessage() . "\n";
}
```

### 2. Asynchronous / Concurrent Quickstart (Multi-cURL Execution Pool)

[](#2-asynchronous--concurrent-quickstart-multi-curl-execution-pool)

Perfect for checking the status of multiple payments in parallel, reducing latency by up to $N$ times with **zero external dependencies**:

```
use HimoSoft\Payments\HimoSoftPaymentsClient;

$client = new HimoSoftPaymentsClient("your_api_key", "your_api_secret", "https://pay.himosoft.com.bd");

// 1. Queue multiple requests asynchronously inside the cURL pool
$client->getPaymentStatusAsync("payment_id_1", function($response) {
    echo "Payment 1 is currently: " . $response['status'] . "\n";
}, function($error) {
    echo "Payment 1 check failed: " . $error->getMessage() . "\n";
});

$client->getPaymentStatusAsync("payment_id_2", function($response) {
    echo "Payment 2 is currently: " . $response['status'] . "\n";
}, function($error) {
    echo "Payment 2 check failed: " . $error->getMessage() . "\n";
});

// 2. Dispatch all queued requests concurrently in a single non-blocking session!
$client->executeAsync();
```

---

📖 API Reference Guide
---------------------

[](#-api-reference-guide)

### 1. Create Payment

[](#1-create-payment)

```
$client->createPayment([
    "amount" => "500.00",              // string: Payment volume (e.g. "500.00")
    "currency" => "BDT",            // string: "BDT" or "USD"
    "reference_id" => "INV-99",     // string: Your unique reference ID
    "description" => "Plan Buy",     // string: Description
    "redirect_url" => "https://...", // string: Success redirect URL

    // Required Customer Metadata
    "customer_id" => "CUST-100",
    "customer_email" => "mail@example.com",
    "customer_name" => "Customer Name",

    // Required Product Metadata
    "product_name" => "Product Name",
    "product_price" => "500.00",
    "product_quantity" => 1,

    // Optional parameters (Populated with system defaults if left empty)
    "idempotency_key" => "...",     // string: Will auto-generate a secure UUID4 if empty
    "customer_phone" => "...",      // string: Default: "01316100897"
    "customer_address" => "...",    // string: Default: "Dhaka, Bangladesh"
    "product_image" => "...",       // string: Default: "https://himosoft.com.bd"
    "product_url" => "...",         // string: Default: "https://himosoft.com.bd"
    "custom_metadata" => []         // array: Associative array of custom tags to store on the invoice
]);
```

### 2. Get Payment Status (Reconcile)

[](#2-get-payment-status-reconcile)

```
$client->getPaymentStatus($paymentId);
```

### 3. Quick DB Status Only Check

[](#3-quick-db-status-only-check)

```
$client->verifyPayment($paymentId);
```

### 4. Force Live Gateway Reconciliation Check

[](#4-force-live-gateway-reconciliation-check)

```
$client->recheckPayment($paymentId);
```

### 5. Cancel Pending Session

[](#5-cancel-pending-session)

```
$client->cancelPayment($paymentId);
```

### 6. Verify Webhook Signature (Callback protection)

[](#6-verify-webhook-signature-callback-protection)

```
use HimoSoft\Payments\HimoSoftPaymentsClient;

// Read headers and payload from request
$payload = json_decode(file_get_contents('php://input'), true);
$signatureHeader = $_SERVER['HTTP_X_SIGNATURE'] ?? '';
$timestampHeader = $_SERVER['HTTP_X_TIMESTAMP'] ?? '';

// Verify incoming webhook signature to protect against tampering
$isValid = HimoSoftPaymentsClient::verifyWebhookSignature(
    $payload,
    $signatureHeader,
    $timestampHeader,
    "your_merchant_secret"
);

if ($isValid) {
    // Process the webhook event securely
} else {
    // Reject request (401 Unauthorized / tampered)
}
```

---

🛡️ Robust Exception Handling
----------------------------

[](#️-robust-exception-handling)

You can catch specific failure states inheriting from `HimoSoftException`:

```
use HimoSoft\Payments\Exceptions\HimoSoftException;
use HimoSoft\Payments\Exceptions\HimoSoftAuthException;
use HimoSoft\Payments\Exceptions\HimoSoftValidationException;
use HimoSoft\Payments\Exceptions\HimoSoftApiException;

try {
    $payment = $client->createPayment([...]);
} catch (HimoSoftAuthException $e) {
    // Unauthorized, invalid API key, or bad signature
} catch (HimoSoftValidationException $e) {
    // Missing required fields locally or remote validation errors
} catch (HimoSoftApiException $e) {
    // Server responded with an error (e.g. 400 Bad Request, 429 Throttled)
    echo "API HTTP Code: " . $e->getStatusCode() . "\n";
    print_r($e->getResponseBody());
} catch (HimoSoftException $e) {
    // Base fallback error
}
```

---

🔒 Security Best Practices
-------------------------

[](#-security-best-practices)

1. **Environment Variables**: Never commit your `apiSecret` directly in source code repositories. Securely load them using variables (e.g., in Laravel `.env` file): ```
    $apiSecret = env('HIMOSOFT_API_SECRET');
    ```
2. **Raw JSON Signature Alignment**: The HimoSoft SDK utilizes PHP native `hash_hmac` alongside `JSON_UNESCAPED_SLASHES` to seal requests. Using raw CURL manually to sign URLs or nested JSON arrays might bypass these constraints and lead to `401 Unauthorized` responses. Always prefer the SDK wrapper methods.

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance58

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/50d28ecd28f842dac295b8aa32dc21a7c8cc33c99fb07963bc88c3b76aae5754?d=identicon)[phpops](/maintainers/phpops)

---

Top Contributors

[![Swe-HimelRana](https://avatars.githubusercontent.com/u/28831625?v=4)](https://github.com/Swe-HimelRana "Swe-HimelRana (1 commits)")

### Embed Badge

![Health badge](/badges/himosoft-payments/health.svg)

```
[![Health](https://phpackages.com/badges/himosoft-payments/health.svg)](https://phpackages.com/packages/himosoft-payments)
```

###  Alternatives

[pagseguro/php

Biblioteca de integração com o PagSeguro

23260.3k6](/packages/pagseguro-php)[dinkbit/conekta-cashier

Dinkbit Cashier nos da una interface para cobrar subscripciones con Conketa en Laravel.

365.4k](/packages/dinkbit-conekta-cashier)[msilabs/bkash

bKash Payment Gateway API for Laravel Framework.

181.4k](/packages/msilabs-bkash)[binkode/laravel-paystack

A description for laravel-paystack.

112.1k](/packages/binkode-laravel-paystack)

PHPackages © 2026

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