PHPackages                             unicloudvn/klbpay-php-sdk - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. unicloudvn/klbpay-php-sdk

ActiveLibrary[HTTP &amp; Networking](/categories/http)

unicloudvn/klbpay-php-sdk
=========================

Client library for Kien Long bank pay

v1.0(2y ago)0179↓36.2%MITPHPPHP &gt;=7.3

Since Apr 4Pushed 2y ago1 watchersCompare

[ Source](https://github.com/unicloudvn/KLBPay-PHP-SDK)[ Packagist](https://packagist.org/packages/unicloudvn/klbpay-php-sdk)[ Docs](https://kienlongbank.com/)[ RSS](/packages/unicloudvn-klbpay-php-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (5)Used By (0)

KLBPay-PHP-SDK
==============

[](#klbpay-php-sdk)

Thư viện người dùng tích hợp KLBPay vào hệ thống thanh toán của Merchant

PHP
===

[](#php)

Github:

**Cài đặt và sử dụng**
----------------------

[](#cài-đặt-và-sử-dụng)

### **Requirements**

[](#requirements)

Phiên bản PHP: từ 7.4 trở lên. Ngoài ra cần một số extension của php như php-oauth.

Ví dụ cài đặt trên Linux

```
sudo install php-oauth
```

hoặc

```
sudo install php-oauth
sudo install php7.4-oauth
```

### **Composer**

[](#composer)

Để cài đặt các ràng buộc bằng [Composer](https://getcomposer.org/). Làm theo [hướng dẫn cài đặt](https://getcomposer.org/doc/00-intro.md) nếu bạn chưa cài đặt Composer.

Chạy dòng lệnh:

```
composer require unicloudvn/klbpay-php-sdk
```

Kiểm tra phần sau ở file composer.json:

```
{
  "require": {
        "unicloudvn/klbpay-php-sdk": "^1.0"
    }
}
```

Cuối cùng, hãy chắc chắn đã bao gồm autoloader:

```
require_once '/path/to/your-project/vendor/autoload.php';
```

### **Cài đặt thủ công:**

[](#cài-đặt-thủ-công)

Bước 1. Tải thư mục sdk vào dự án của bạn.

Bước 2. cd đến vị trí thư mục composer.json của sdk. Chạy commandLine: `composer install`.

**Cách sử dụng:**
-----------------

[](#cách-sử-dụng)

### **Imports**

[](#imports)

```
require_once '/path/to/your-project/vendor/autoload.php';
```

### **Constants**

[](#constants)

```
const HOST = ''; //'https://api-staging.kienlongbank.co/pay'
const CLIENT_ID = '';
const SECRET_KEY = '';
const ENCRYPT_KEY = '';
const ACCEPT_TIME_DIFF = '';
```

### **Configure**

[](#configure)

```
$kPayPacker = new KPayPacker(
    CLIENT_ID,
    ENCRYPT_KEY,
    SECRET_KEY,
    ACCEPT_TIME_DIFF,
    HOST
);

$payClient = new KPayClient($kPayPacker);
```

**Ví dụ cơ bản**
----------------

[](#ví-dụ-cơ-bản)

Trong dự án của bạn:

Bước 1. Tạo thư mục `/assets` -&gt; tạo các files:

- Bootstrap v3.3.4 - `bootstrap.min.css`.
- jQuery v1.11.3 - `jquery-1.11.3.min.js`.
- Jumbotron-narrow - `jumbotron-narrow.css`:

```
/* Space out content a bit */
body {
    padding-top: 20px;
    padding-bottom: 20px;
}

/* Everything but the jumbotron gets side spacing for mobile first views */
.header,
.marketing,
.footer {
    padding-right: 15px;
    padding-left: 15px;
}

/* Custom page header */
.header {
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e5e5;
}

/* Make the masthead heading the same height as the navigation */
.header h3 {
    margin-top: 0;
    margin-bottom: 0;
    line-height: 40px;
}

/* Custom page footer */
.footer {
    padding-top: 19px;
    color: #777;
    border-top: 1px solid #e5e5e5;
}

/* Customize container */
@media (min-width: 768px) {
    .container {
        max-width: 970px;
    }
}

.container-narrow > hr {
    margin: 30px 0;
}

/* Main marketing message and sign up button */
.jumbotron {
    text-align: center;
    border-bottom: 1px solid #e5e5e5;
}

.jumbotron .btn {
    padding: 14px 24px;
    font-size: 21px;
}

/* Supporting marketing content */
.marketing {
    margin: 40px 0;
}

.marketing p + h4 {
    margin-top: 28px;
}

/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
    /* Remove the padding we set earlier */
    .header,
    .marketing,
    .footer {
        padding-right: 0;
        padding-left: 0;
    }

    /* Space out the masthead */
    .header {
        margin-bottom: 30px;
    }

    /* Remove the bottom border on the jumbotron for visual effect */
    .jumbotron {
        border-bottom: 0;
    }
}

.pay-success {
    color: blue;
}

.pay-unsuccess {
    color: black;
}

.pay-error {
    color: red;
}

.footer {
    text-align: center
}

/* Pager */
.pager {
    margin: 8px 3px;
    padding: 3px;
}

.pager .disabled {
    border: 1px solid #ddd;
    color: #999;
    margin-top: 4px;
    padding: 3px;
    text-align: center;
}

.pager .current {
    background-color: #6ea9bf;
    border: 1px solid #6e99aa;
    color: #fff;
    font-weight: bold;
    margin-top: 4px;
    padding: 3px 5px;
    text-align: center;
}

.pager span, .pager a {
    margin: 4px 3px;
}

.pager a {
    border: 1px solid #aaa;
    padding: 3px 5px;
    text-align: center;
    text-decoration: none;
}
```

Bước 2. Tạo index.php trên thư mục root của dự án.

```
DOCTYPE html>

    Test Transaction

        KLBPAY DEMO

    Tạo mới giao dịch

                Mã giao dịch
