ninepay-gateway / rest-client-php
Official PHP SDK for 9PAY Payment Gateway
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/ninepay-gateway/rest-client-php
Requires
- php: >=7.4 <9.0
- ext-json: *
- ext-openssl: *
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2026-01-15 02:09:22 UTC
README
Official PHP SDK for integrating 9PAY Payment Gateway.
Supports PHP Native, Laravel, and Lumen.
This package allows you to:
- Create payment requests
- Query transaction status
- Verify webhook / callback data
- Integrate easily using OOP, SOLID & Facade pattern
Table of Contents
Requirements
- PHP >= 7.4
- Extensions:
jsonopenssl
Installation
Install the SDK via Composer:
composer require ninepay-gateway/rest-client-php
Configuration
PHP Native
$config = [ 'merchant_id' => 'YOUR_MERCHANT_ID', 'secret_key' => 'YOUR_SECRET_KEY', 'checksum_key' => 'YOUR_CHECKSUM_KEY', 'env' => 'SANDBOX', ];
Laravel
php artisan vendor:publish --tag=ninepay-config
NINEPAY_MERCHANT_ID=your_merchant_id NINEPAY_SECRET_KEY=your_secret_key NINEPAY_CHECKSUM_KEY=your_checksum_key NINEPAY_ENV=SANDBOX
Lumen
mkdir -p config cp vendor/ninepay-gateway/rest-client-php/config/ninepay.php config/ninepay.php
$app->register(NinePay\NinePayServiceProvider::class); $app->configure('ninepay');
$app->withFacades(); class_alias(NinePay\Facades\NinePay::class, 'NinePay');
Usage
Initialization
use NinePay\PaymentManager; $manager = new PaymentManager($config); $gateway = $manager->getGateway();
use NinePay; $gateway = NinePay::getGateway();
Create Payment
use NinePay\Support\CreatePaymentRequest; $request = new CreatePaymentRequest( 'INV123456', '50000', 'Payment for order #123', 'https://your-site.com/callback', 'https://your-site.com/return' ); $response = $gateway->createPayment($request); if ($response->isSuccess()) { header('Location: ' . $response->getData()['redirect_url']); exit; } echo $response->getMessage();
Query Transaction
$response = $gateway->inquiry('9PAY_TRANSACTION_ID'); if ($response->isSuccess()) { print_r($response->getData()); }
Verify Webhook / Callback
$result = $_POST['result'] ?? ''; $checksum = $_POST['checksum'] ?? ''; if ($gateway->verify($result, $checksum)) { $decoded = $gateway->decodeResult($result); $data = json_decode($decoded, true); } else { http_response_code(400); }
Error Handling
use NinePay\Exceptions\PaymentException; try { $gateway->createPayment($request); } catch (PaymentException $e) { logger()->error($e->getMessage()); }
Testing
composer test
Security
Please report security issues to hotro@9pay.vn.
License
MIT License © 9Pay