nictbd/php-sdk

NICTBD.COM PHP SDK for Payment Gateway integration

Maintainers

Package info

github.com/nictbd/nictbd-php-sdk

pkg:composer/nictbd/php-sdk

Transparency log

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-13 23:13 UTC

This package is auto-updated.

Last update: 2026-07-13 23:44:26 UTC


README

Official PHP SDK for NICTBD.COM Payment Gateway.

Requirements

  • PHP 8.1 or higher
  • cURL extension enabled
  • Valid NICTBD.COM merchant API credentials

Installation

composer require nictbd/php-sdk

Basic Usage

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Nictbd\Client;

$client = new Client([
    'base_url' => 'https://nictbd.com',
    'store_id' => 'STORE_ID',
    'api_key' => 'API_KEY',
    'secret_key' => 'SECRET_KEY',
]);

$response = $client->createPayment([
    'amount' => 100,
    'tran_id' => 'INV001',
    'currency' => 'BDT',
    'customer_name' => 'Customer Name',
    'customer_mobile' => '01700000000',
    'customer_email' => 'customer@example.com',
    'success_url' => 'https://merchant.com/payment/success',
    'failed_url' => 'https://merchant.com/payment/failed',
    'cancel_url' => 'https://merchant.com/payment/cancel',
    'webhook_url' => 'https://merchant.com/api/payment/webhook',
]);

if (($response['status'] ?? null) === 'success') {
    header('Location: ' . $response['payment_url']);
    exit;
}

echo $response['message'] ?? 'Payment create failed';

Laravel Configuration

Add credentials to your .env file:

NICTBD_BASE_URL=https://nictbd.com
NICTBD_STORE_ID=STORE_ID
NICTBD_API_KEY=API_KEY
NICTBD_SECRET_KEY=SECRET_KEY

Add this to config/services.php:

'nictbd' => [
    'base_url' => env('NICTBD_BASE_URL', 'https://nictbd.com'),
    'store_id' => env('NICTBD_STORE_ID'),
    'api_key' => env('NICTBD_API_KEY'),
    'secret_key' => env('NICTBD_SECRET_KEY'),
],

Laravel controller example:

use Nictbd\Client;

public function pay()
{
    $client = new Client([
        'base_url' => config('services.nictbd.base_url'),
        'store_id' => config('services.nictbd.store_id'),
        'api_key' => config('services.nictbd.api_key'),
        'secret_key' => config('services.nictbd.secret_key'),
    ]);

    $response = $client->createPayment([
        'amount' => 100,
        'tran_id' => 'INV' . now()->format('YmdHis'),
        'currency' => 'BDT',
        'customer_name' => 'Customer Name',
        'customer_mobile' => '01700000000',
        'customer_email' => 'customer@example.com',
        'success_url' => route('payment.success'),
        'failed_url' => route('payment.failed'),
        'cancel_url' => route('payment.cancel'),
        'webhook_url' => route('payment.webhook'),
    ]);

    if (($response['status'] ?? null) === 'success') {
        return redirect()->away($response['payment_url']);
    }

    return back()->with('error', $response['message'] ?? 'Payment create failed');
}

Verify Payment

$response = $client->verifyPayment('INV001');

if (($response['status'] ?? null) === 'success') {
    // Payment verified successfully.
}

Webhook Signature Verification

use Nictbd\Signature;

$isValid = Signature::verifyWebhook(
    $payload['tran_id'] ?? '',
    $payload['amount'] ?? '',
    $payload['status'] ?? '',
    $payload['signature'] ?? '',
    'SECRET_KEY'
);

if (! $isValid) {
    http_response_code(401);
    exit('Invalid signature');
}

Notes

  • Keep your Secret Key only on your backend server.
  • Never expose Secret Key in frontend JavaScript, mobile app source code or public repository.
  • Always verify webhook signature before updating order status.
  • Use unique tran_id for every payment request.