PHPackages                             ninepay-gateway/rest-client-php - 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. ninepay-gateway/rest-client-php

ActiveLibrary[Payment Processing](/categories/payments)

ninepay-gateway/rest-client-php
===============================

Official PHP SDK for 9PAY Payment Gateway

19PHPCI failing

Since Apr 13Pushed 2mo agoCompare

[ Source](https://github.com/9pay-labs/9pay-sdk-php)[ Packagist](https://packagist.org/packages/ninepay-gateway/rest-client-php)[ RSS](/packages/ninepay-gateway-rest-client-php/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (8)Used By (0)

9PAY Payment Gateway PHP SDK
============================

[](#9pay-payment-gateway-php-sdk)

 [ ![Latest Version](https://camo.githubusercontent.com/44fd226b826ffadacb40cd0326c06a1281100e9dfc2d961b864644642e957905/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e696e657061792d676174657761792f726573742d636c69656e742d7068702e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/ninepay-gateway/rest-client-php) [ ![Build Status](https://camo.githubusercontent.com/7dcd57f22e5d397a71b9698c80a53d43352412c41f6cb36ffd25cb56db0a2367/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c642d70617373696e672d627269676874677265656e3f7374796c653d666c61742d737175617265) ](https://github.com/ninepay-gateway/rest-client-php/actions) [ ![Total Downloads](https://camo.githubusercontent.com/f88cada77aac55a410e4d956659c89ab37798648bb71154d76d2f888a4ad1523/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e696e657061792d676174657761792f726573742d636c69656e742d7068702e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/ninepay-gateway/rest-client-php) [ ![License](https://camo.githubusercontent.com/ea5a7b5faae59ce0a8bf5dff1e4dc95d88105b21be691ad354c4a7058799800b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e696e657061792d676174657761792f726573742d636c69656e742d7068702e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/ninepay-gateway/rest-client-php)

Official PHP SDK for integrating **9PAY Payment Gateway**.
Supports **PHP Native**, **Laravel**, and **Lumen**.

Features
--------

[](#features)

The SDK currently supports:

- Create payment request
- Query transaction status
- Verify webhook / callback signature
- Refund transaction
- Payer authentication for installment payments
- Credit card authorization
- Capture authorized payment
- Reverse authorization
- Strong typed request objects
- Laravel &amp; Lumen integration
- OOP &amp; SOLID compliant architecture

---

Table of Contents
-----------------

[](#table-of-contents)

- Requirements
- Installation
- Configuration
- PHP Native
- Laravel
- Lumen
- Usage
- Initialization
- Create Payment
- Query Transaction
- Verify Webhook
- Refund Transaction
- Payer Authentication
- Authorize Card Payment
- Capture Authorized Payment
- Reverse Authorization
- Enums
- License

---

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4
- Required extensions:
- json
- openssl

---

Installation
------------

[](#installation)

Install via Composer:

```
composer require ninepay-gateway/rest-client-php
```

---

Configuration
-------------

[](#configuration)

### PHP Native

[](#php-native)

```
use NinePay\Config\NinePayConfig;
use NinePay\Gateways\NinePayGateway;

$config = new NinePayConfig(
    'MERCHANT_ID',
    'SECRET_KEY',
    'CHECKSUM_KEY',
    'https://your-endpoint-url'
);

$gateway = new NinePayGateway($config);
```

You may also create configuration from array:

```
$config = NinePayConfig::fromArray([
    'merchant_id' => 'MID',
    'secret_key' => 'SECRET',
    'checksum_key' => 'CHECKSUM',
    'endpoint' => 'https://your-endpoint-url',
]);
```

---

### Laravel

[](#laravel)

Publish configuration file:

```
php artisan vendor:publish --tag=ninepay-config
```

Then configure environment variables:

```
NINEPAY_MERCHANT_ID=your_merchant_id
NINEPAY_SECRET_KEY=your_secret_key
NINEPAY_CHECKSUM_KEY=your_checksum_key
NINEPAY_ENDPOINT=https://your-endpoint-url
```

After configuration, the gateway is automatically resolved via Laravel's service container.

Usage requires only the Facade:

```
use NinePay\Facades\NinePay;

$response = NinePay::createPayment($request);
```

Example in controller:

```
public function pay()
{
    $request = new CreatePaymentRequest(
        'INV_' . time(),
        50000,
        'Payment Order',
        route('payment.return'),
        route('payment.cancel')
    );

    $response = NinePay::createPayment($request);

    return redirect($response->getData()['redirect_url']);
}
```

---

### Lumen

[](#lumen)

Copy config file:

```
cp vendor/ninepay-gateway/rest-client-php/config/ninepay.php config/ninepay.php
```

Register provider in `bootstrap/app.php`:

```
$app->register(NinePay\NinePayServiceProvider::class);
$app->configure('ninepay');
```

Enable facades:

```
$app->withFacades();
class_alias(NinePay\Facades\NinePay::class, 'NinePay');
```

---

Usage
-----

[](#usage)

### Initialization

[](#initialization)

PHP Native:

```
use NinePay\Config\NinePayConfig;
use NinePay\Gateways\NinePayGateway;

$config = new NinePayConfig('MID', 'SECRET', 'CHECKSUM', 'https://your-endpoint-url');
$gateway = new NinePayGateway($config);
```

Laravel:

```
$response = NinePay::createPayment($request);
```

---

Create Payment
--------------

[](#create-payment)

```
use NinePay\Request\CreatePaymentRequest;
use NinePay\Enums\Currency;
use NinePay\Enums\Language;
use NinePay\Enums\TransactionType;

$request = new CreatePaymentRequest(
    'INV_' . time(),
    3100000,
    'Payment for Order',
    'https://site.com/return',
    'https://site.com/cancel'
);

$request
    ->withClientIp('127.0.0.1')
    ->withCurrency(Currency::VND)
    ->withLang(Language::VI)
    ->withTransactionType(TransactionType::INSTALLMENT)
    ->withExpiresTime(1440);

$response = $gateway->createPayment($request);
```

---

Query Transaction
-----------------

[](#query-transaction)

```
$response = $gateway->inquiry('INV_123456');

if ($response->isSuccess()) {
    print_r($response->getData());
}
```

---

Verify Webhook
--------------

[](#verify-webhook)

```
$result = $_POST['result'] ?? '';
$checksum = $_POST['checksum'] ?? '';

if ($gateway->verify($result, $checksum)) {

    $json = $gateway->decodeResult($result);
    $data = json_decode($json, true);

    $invoiceNo = $data['invoice_no'];
    $status = $data['status'];

    echo 'OK';
} else {
    http_response_code(400);
    echo 'Checksum Mismatch';
}
```

---

Refund Transaction
------------------

[](#refund-transaction)

```
use NinePay\Request\CreateRefundRequest;
use NinePay\Enums\Currency;

$request = new CreateRefundRequest(
    'REF_' . time(),
    436271072913641,
    3100000,
    'Refund reason'
);

$request->withCurrency(Currency::VND)
        ->withBank(
            'BIDV',
            '1023020330000',
            'NGUYEN VAN A'
        );

$response = $gateway->refund($request);
```

---

Payer Authentication
--------------------

[](#payer-authentication)

```
use NinePay\Request\PayerAuthRequest;

$request = new PayerAuthRequest(
    'REQ_' . time(),
    5000000,
    'https://site.com/return'
);

$request->withInstallment(5000000, 'VCB', 12)
        ->withCard(
            '4456530000001005',
            'NGUYEN VAN A',
            '12',
            '27',
            '123'
        );

$response = $gateway->payerAuth($request);
```

---

Authorize Card Payment
----------------------

[](#authorize-card-payment)

```
use NinePay\Request\AuthorizeCardPaymentRequest;
use NinePay\Enums\Currency;

$request = new AuthorizeCardPaymentRequest(
    'REQ_' . time(),
    436271072913641,
    3100000,
    Currency::VND
);

$request->withCard(
    '4456530000001005',
    'NGUYEN VAN A',
    '12',
    '27',
    '123'
);

$response = $gateway->authorizeCardPayment($request);
```

---

Capture Authorized Payment
--------------------------

[](#capture-authorized-payment)

```
use NinePay\Request\CapturePaymentRequest;
use NinePay\Enums\Currency;

$request = new CapturePaymentRequest(
    'REQ_' . time(),
    436272499763441,
    20000,
    Currency::VND
);

$response = $gateway->capture($request);
```

---

Reverse Authorization
---------------------

[](#reverse-authorization)

```
use NinePay\Request\ReverseCardPaymentRequest;

$request = new ReverseCardPaymentRequest(
    'REQ_' . time(),
    436272499763441,
    3100000,
    'VND'
);

$request->withCard(
    '4456530000001005',
    'NGUYEN VAN A',
    '12',
    '27',
    '123'
);

$response = $gateway->reverseCardPayment($request);
```

---

Enums
-----

[](#enums)

### Currency

[](#currency)

Supported examples:

```
VND, USD, EUR, JPY, AUD, ...

```

### Language

[](#language)

```
VI, EN

```

### Transaction Type

[](#transaction-type)

```
INSTALLMENT
CARD_AUTHORIZATION

```

---

License
-------

[](#license)

MIT License © 9Pay

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance56

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity19

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.

###  Release Activity

Cadence

Every ~7 days

Total

5

Last Release

141d ago

Major Versions

v1.3.0 → v2.0.02026-02-12

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/254416958?v=4)[9PAY](/maintainers/9pay-labs)[@9pay-labs](https://github.com/9pay-labs)

---

Top Contributors

[![lamnm-9pay](https://avatars.githubusercontent.com/u/254406354?v=4)](https://github.com/lamnm-9pay "lamnm-9pay (3 commits)")

---

Tags

9paylaravelphpsdk

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ninepay-gateway-rest-client-php/health.svg)

```
[![Health](https://phpackages.com/badges/ninepay-gateway-rest-client-php/health.svg)](https://phpackages.com/packages/ninepay-gateway-rest-client-php)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M736](/packages/sylius-sylius)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M420](/packages/drupal-core-recommended)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

5.1k5.2k](/packages/shlinkio-shlink)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)

PHPackages © 2026

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