.
Giới thiệu Bảo Kim API
Bảo Kim Payment Platform là một nền tảng thanh toán mở, Bảo Kim cung cấp đầy đủ các API cho phép user tích hợp giữa ứng dụng (web/app) của mình với Bảo Kim nhằm thực hiện việc nhận thanh toán đơn hàng, kiểm tra tài khoản, đối soát giao dịch, thực hiện giao dịch tự động, ...
Ví dụ user có thể thực hiện các tác vụ sau với Bảo Kim API
- Nhận thanh toán tiền cho đơn hàng phát sinh trên ứng dụng (web/app) của mình bằng cách gửi đơn hàng sang Bảo Kim và hiển thị giao diện thanh toán để người mua thanh toán.
- Đối soát thông tin tài khoản, số dư, giao dịch, danh sách đơn hàng, trạng thái thanh toán đơn hàng nhằm thực hiện việc đối soát
- Thực hiện giao dịch tự động như rút tiền, chuyển tiền, hoàn tiền cho user khác.
- Mua các dịch vụ gia tăng (topup/mã thẻ/thẻ game/...)
- ...
Phương thức bảo mật
Bảo mật Bảo Kim API sử dụng các phương thức sau đây
- Json Web Token (JWT), là tham số bắt buộc đối với mọi request đến API, các bước thực hiện:
- Tự cấp phát API Key gồm 1 cặp khóa bí mật key/secret Tại đây
- Sử dụng API Key được cấp phát ở trên và thuật toán mã hóa HS256 để mã hóa ra JWT (xem code mẫu)
- Nếu là request POST, dữ liệu post (request body) cần được truyên vào trường 'form_params' trong payload data của jwt để xác thực signature (xem code mẫu)
- Thời gian hết hạn tối đa của jwt là 60s kể từ khi tạo
- Khi request đến API cần truyền jwt bằng 1 trong 2 phương thức: Request Header jwt = Bearer $JWT / Query parameter(url param) &jwt=$JWT
- Verify Signature (Áp dụng với các API có Request Method là "POST")
- Đối với các API có Request Method "POST" (phát sinh GD hoặc dữ liệu), Bảo Kim sẽ tiến hành verify thêm signature (trên jwt) để đảm bảo toàn vẹn dữ liệu
- Cơ chế kiểm tra: giải mã payload data trong jwt, so sánh dữ liệu trong form_params và dữ liệu post lên có trùng khớp hay không
- Cách truyền dữ liệu post vào 'form_params' trong payload data để mã hóa jwt xin hãy xem code mẫu
//PHP JWT example
require_once('vendor/autoload.php');
use \Firebase\JWT\JWT;
class BaoKimAPI {
/* Bao Kim API key */
const API_KEY = "x***";
const API_SECRET = "y***";
const TOKEN_EXPIRE = 60; //token expire time in seconds
const ENCODE_ALG = 'HS256';
private static $_jwt = null;
/**
* Refresh JWT
*/
public static function refreshToken(){
$tokenId = base64_encode(mcrypt_create_iv(32));
$issuedAt = time();
$notBefore = $issuedAt;
$expire = $notBefore + self::TOKEN_EXPIRE;
/*
* Payload data of the token
*/
$data = [
'iat' => $issuedAt, // Issued at: time when the token was generated
'jti' => $tokenId, // Json Token Id: an unique identifier for the token
'iss' => self::API_KEY, // Issuer
'nbf' => $notBefore, // Not before
'exp' => $expire, // Expire
'form_params' => [ // request body (dữ liệu post)
//'a' => 'value a',
//'b' => 'value b',
]
];
/*
* Encode the array to a JWT string.
* Second parameter is the key to encode the token.
*
* The output string can be validated at http://jwt.io/
*/
self::$_jwt = JWT::encode(
$data, //Data to be encoded in the JWT
self::API_SECRET, // The signing key
'HS256' // Algorithm used to sign the token, see https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40#section-3
);
return self::$_jwt;
}
/**
* Get JWT
*/
public static function getToken(){
if(!self::$_jwt)
self::refreshToken();
try {
JWT::decode(self::$_jwt, self::API_SECRET, array('HS256'));
}catch(Exception $e){
self::refreshToken();
}
return self::$_jwt;
}
}
API endpoint
Bảo Kim API endpoint (đường dẫn đầy đủ gọi API) được xác định như sau:
Môi trường production (thật)
- https://api.baokim.vn/payment/ + API_URI
Môi trường sandbox (test)
- https://sandbox-api.baokim.vn/payment/ + API_URI
Trong đó API_URI được mô tả trong phần tài liệu chi tiết của từng API
Môi trường Sandbox(test)
- API Endpoint: https://sandbox-api.baokim.vn/payment/ + API_URI
- API key/sec: a18ff78e7a9e44f38de372e093d87ca1 / 9623ac03057e433f95d86cf4f3bef5cc
- Web URL: http://sandbox.baokim.vn
- Web login account: 2@bk.vn / 2 (Vui lòng không tạo api key mới cho tài khoản này)
- Thẻ test thanh toán ATM online
- Ngân hàng: Saigonbank
- Số thẻ: 9704000000000018
- Tên chủ thẻ: NGUYEN VAN A
- Ngày phát hành: 03/07
- Mật khẩu OTP: otp
- Thẻ test thanh toán Mastercard
- Số thẻ: 5123450000000008
- Ngày phát hành: 05/21
- CVN: 100
Bắt đầu ngay
Để bắt đầu sử dụng Bảo Kim API bạn chỉ cần thực hiện các bước hết sức đơn giản và nhanh chóng sau đây
- Đăng ký tài khoản ví điện tử Bảo Kim nếu chưa có tài khoản, Đăng ký
- Đăng nhập và tự cấp phát API Key gồm 1 cặp khóa bí mật key/secret Tại đây
- Sử dụng API và thuật toán mã há HS256 để mã hóa Json Web Token: xem Phương thức bảo mật
- Bắt đầu tích hợp với các API theo nhu cầu ứng dụng của bạn:
- Tích hợp thanh toán đơn hàng/nội dung số/..., Xem quy trình tích hợp
- Truy xuất thông tin tài khoản với Account API
- Đối soát giao dịch với Transaction API
- Chuyển tiền tự động với Transfer API
- Rút tiền về ngân hàng tự động với Withdraw API
- Hoàn tiền tự động với Refund API
- Mua dịch vụ VAT với VAT API
- ...
Tích hợp thanh toán
Bảo Kim cung cấp quy trình và các API cho phép tích hợp thanh toán đơn hàng/sản phẩm từ các website/app thương mại điện tử/nội dung số... Nhằm phục vụ cho việc xử lý thanh toán khi khách hàng mua sắm trực tuyến một cách an toàn và tiện lợi.
Trước khi bắt đầu, hãy đảm bảo rằng bạn
- Hiểu rõ phương thức bảo mật và các bước kết nối đến Bảo Kim API
- Hiểu rõ và lựa chọn một trong hai quy trình tích hợp phù hợp với nhu cầu dưới đây (cơ bản/pro).
- Nếu bạn cần tích hợp thử trên môi trường Sandbox (test), xin hãy xem thông tin tích hợp tại Môi trường Sandbox
- Bảo Kim giới hạn 30.000đ/1 giao dịch dối với user chưa xác thực Xác thực ngay
Demo thanh toán với Bảo Kim
Quy trình tích hợp cơ bản
Đây là quy trình tích hợp đơn giản và nhanh chóng nhất, tuy nhiên xin hãy tìm hiểu thêm về quy trình tích hợp Pro phía dưới với nhiều ưu điểm hơn để có lựa chọn phù hợp.
Ưu điểm:
- Tích hợp đơn giản, chỉ xử lý 2 bước chính là gửi order yêu cầu thanh toán (API Send Order) và xác nhận kết quả thanh toán.
Nhược điểm:
- Khách hàng không xem được các phương thức thanh toán để lựa chọn (vd danh sách ngân hàng...) ngay trên giao diện của merchant. Khách hàng sẽ lựa chọn phương thức thanh toán trên giao diện thanh toán của Bảo Kim.
Quy trình tích hợp Pro (nâng cao)
Về mặt kỹ thuật, điểm khác biệt duy nhất của tích hợp Pro so với tích hợp cơ bản là Web/App merchant sử dụng API Bank Payment Method List để load danh sách phương thức thanh toán và hiển thị trên giao diện của mình cho user chọn, sau đó gửi các tham số này cùng với đơn hàng sang Bảo Kim qua API Send Order
Ưu điểm chính của tích hợp Pro:
- Web/App merchant có thể hiển thị danh sách phương thức thanh toán khách hàng có thể sử dụng (ví Bảo Kim, các Ngân Hàng),
- Khi khách hàng đã chọn phương thức thanh toán, quá trình thanh toán sẽ chuyển trực tiếp từ Web/App merchant sang trang ngân hàng (không hiển thị trang thanh toán Bảo Kim)
- Khách hàng cảm thấy Web/App merchant chấp nhận thanh toán hầu hết các ngân hàng trong nước, tăng độ tin cậy, chuyên nghiệp, biết trước các lựa chọn thanh toán mình có
Nhược điểm:
- Phải xử lý kỹ thuật để hiển thị các phương thức thanh toán trên giao diện của Web/App merchant.
Thanh toán qua Internet Banking
Về cơ bản, thanh toán qua Internet Banking chỉ là một phương thức thanh toán thuộc các quy trình tích hợp trên (basic/pro), web/app merchant có thể đơn giản là không cần xử lý gì thêm.
Tuy nhiên, nếu bạn muốn đơn giản hơn cho khách hàng bằng cách hiển thị luôn thông tin tài khoản Internet Banking nhận tiền trên giao diện của mình thay vì phải redirect sang Bảo Kim, hãy xử lý theo quy trình rút ngắn dưới đây:
Thanh toán sử dụng QRCode
Thanh toán QRCode là một phương thức thanh toán thuộc các quy trình tích hợp trên (basic/pro),
khách hàng sử dụng APP ngân hàng để quest mã QR Bảo Kim trả về để thực hiện giao dịch, web/app merchant có thể không cần xử lý gì thêm.
Đối với tích hợp Pro nếu bạn muốn đơn giản hơn cho khách hàng bằng cách hiển thị hình ảnh QRCode trên giao diện của mình thay vì phải redirect sang Bảo Kim, hãy xử lý theo quy trình rút ngắn dưới đây:
Thanh toán Trả góp
Thanh toán trả góp là một phương thức thanh toán thuộc các quy trình tích hợp trên (basic/pro), web/app merchant có thể đơn giản là không cần xử lý gì thêm.
Khách hàng trước khi thanh toán cần thêm một bước chọn Ngân hàng phát hành và thời hạn và trả góp (3/6/9/12 tháng), bạn hãy tham khảo quy trình dưới đây:
Thanh toán qua Tài Khoản Ảo
Function get virtual account
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['mrc_uuid'] = "MdJGucKrjcgl5BT3";
$payload['name'] = "Nguyen Van A";
$payload['mcr_id'] = "15";
$response = $client->request("POST", "https://dev-api.baokim.vn/payment/api/v4/create-virtual-account-payment’);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Data webhook
{
"order":{
"id":77782,
"user_id":1000005,
"mrc_order_id":"5f3e2a0fe5ef3",
"txn_id":104407,
"ref_no":null,
"deposit_id":1221771,
"merchant_id":10,
"total_amount":"100000.00",
"shipping_fee":"0.00",
"tax_fee":"0.00",
"mrc_fee":null,
"description":"Thanh to\u00e1n cho t\u00e0i kho\u1ea3n \u1ea3o 760014844106",
"items":null,
"url_success":null,
"url_cancel":null,
"url_detail":null,
"stat":"c",
"payment_version":"4.0",
"lang":"vi",
"bpm_id":301,
"accept_qrpay":1,
"accept_bank":1,
"accept_cc":1,
"accept_e_wallet":1,
"email":"1@bk.vn",
"name":"Dang Le Duc",
"webhooks":"http:\/\/localhost\/api\/bpn-listener",
"customer_name":"Nguy\u1ec5n Th\u00e0nh Nam",
"customer_email":null,
"customer_phone":null,
"customer_address":"1",
"created_at":"2020-08-20 14:46:02",
"updated_at":"2020-08-20 14:46:02"
},
"txn":{
"user_id":1000005,
"account_id":1001000079,
"deposit_id":1221771,
"amount":92000,
"freeze_amount":0,
"fee_amount":"0.00",
"fee_display":"0.00",
"description":"Thanh to\u00e1n cho \u0111\u01a1n h\u00e0ng 77782",
"bank_ref_no":null,
"ref_no":"PAY_1221771",
"stat":4,
"type":5,
"src_des":"1@bk.vn",
"updated_at":"2020-08-20 14:46:02",
"created_at":"2020-08-20 14:46:02",
"id":104407,
"mrc_order_id":"5f3e2a0fe5ef3",
"total_amount":"100000.00"
},
"sign":"ce74e15ef621bf3c90ad61cdeedb789dc664dc9ca95f87f6ea0ee1d0c890ba09"
}
Thanh toán qua tài khoản ảo là một phương thức thanh toán đơn giản.
Bước 1: Tạo tài khoản ảo cho user
- Gọi tới API 'payment/api/v4/create-virtual-account-payment' kèm các tham số bắt buộc:
- mrc_uuid: mã người dùng của merchant( mã duy nhất)
- name: tên người dùng
- mcr_id: id merchant website tích hợp
Bước 2: Nhận kết quả thanh toán
- Sau khi User thanh toán, Bảo Kim sẽ ghi nhận giao dịch sau đó trả kết quả về cho Merchant thông qua webhook.
Bạn hãy tham khảo quy trình dưới đây:
Thanh toán sử dụng module Checkout
$line_items = [
[
'name' => 'Tên sản phẩm 1',
'description' => 'Mô tả sản phẩm 1',
'images' => ['https://example.com/image-item1.png'],
'amount' => 500000,
'currency' => 'vnd',
'quantity' => 1,
],
[
'name' => 'Tên sản phẩm 2',
'description' => 'Mô tả sản phẩm 2',
'images' => ['https://example.com/image-item2.png'],
'amount' => 100000,
'currency' => 'vnd',
'quantity' => 1,
],
];
//Set up API Key
BaoKimSDK\BaoKim::setKey(your_api_key, your_api_secret);
//create Session
try {
$session = BaoKimSDK\Session::create([
'payment_method_types' => [1, 2, 3],
'mrc_order_id' => 'mrcOrderId_' . time(),
'line_items' => [
[
'name' => 'Tên sản phẩm 1',
'description' => 'Mô tả sản phẩm 1',
'images' => [
'https://example.com/image-item-1.png',
'https://example.com/image-item-1-1.png'
],
'amount' => 500000,
'currency' => 'vnd',
'quantity' => 1,
],
[
'name' => 'Tên sản phẩm 2',
'description' => 'Mô tả sản phẩm 2',
'images' => ['https://example.com/image-item-2.png'],
'amount' => 100000,
'currency' => 'vnd',
'quantity' => 1,
],
],
'success_url' => 'https://example.com/success',
'cancel_url' => 'https://example.com/cancel',
'webhook_url' => 'https://example.com/webhook',
'customer_email' => 'example@gmail.com',
'customer_phone' => '09********',
]
]
]);
header('Location: ' . $session->payment_url);
exit();
} catch(BaoKimSDK\Exceptions\BaoKimException $e) {
error_log($e->getMessage());
}
Bước 1: Cài đặt thư viện
- Mở Terminal và chạy lệnh sau:
composer require baokim/baokim-sdk
- Sau khi cài đặt thành công, chạy lệnh:
composer dump-autoload
Bước 2: Tiến hành tích hợp
Đối với thanh toán một lần (One-time payment), tạo Session thanh toán với line_items. Line_items đại diện cho một danh sách các sản phẩm mà khách hàng đã chọn mua.
Line_items có dạng là 1 array
, format như code mẫu bên phải.
$payment_method_types = [1, 2, 3];
payment_method_types
là một array (1: Thanh toán ATM, 2: Thanh toán QRCode, 3: Thanh toán Visa)
Khi khách hàng thanh toán thành công đơn hàng của họ. Website sẽ chuyển hướng tới success_url
, một trang trên website của bạn để thông báo tới khách hàng rằng đơn hàng của họ đã thành công
Khi khách hàng bấm huỷ thanh toán, Website sẽ chuyển hướng tới cancel_url
. Thông thường, đây là trang trên trang web của bạn mà khách hàng đã xem trước khi chuyển hướng đến Checkout.
Tạo Session thanh toán
Tạo Session thanh toán sẽ trả về một $session
bao gồm thông tin session
được lưu bên phía Bảo Kim, và một payment_url
. Bạn cần redirect trình duyệt tới payment_url
để tiến hành thanh toán
Thư viện JS và Code nhúng
//Nhúng thư viện JS của Bảo Kim lên header của website
<link rel="stylesheet" href="https://cdn.baokim.vn/public/uploads/checkout/baokim.css" />
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script src="https://cdn.baokim.vn/public/uploads/checkout/baokim.js"></script>
//thêm đoạn code sau vào dưới form thanh toán với id là id form checkout.
<div class="btn btn-success" id="check_out"></div>
<script type="text/javascript">
let baokim = new Baokim(
'check_out', // id of css
'WPaHwMXZoCiQ5bgKT0bP5MC05GmOiSG6', // key
true, // is production
{ //order
mrc_order_id: `my_order_id_${Math.random().toString(36).substring(2)}_${Date.now()}`,
total_amount: 20000,
payment_method_type: 'card',
description: 'thanh toan dien thoai iphone xs max gia re',
url_success: 'http://my-merchant.com/callback-success',
url_detail: 'http://my-merchant.com/callback-cancel',
webhook_url: 'http://php5.varnish.dev.baokim.vn/webhook-momo.php',
},
{ // button config
title: 'Thanh toán voi baokim',
style: {
background: '#fff'
}
});
baokim.createBtn();
</script>
Trên trang thanh toán Merchant thêm đoạn code sau vào header của trang web và thay tham số tùy chỉnh theo code mẫu ở bên phải
Xác nhận kết quả thanh toán
Sau khi khách hàng thanh toán thành công, Bảo Kim sẽ gửi thông báo Webhook notification cho Web/App merchant, sau đó redirect trình duyệt khách hàng theo url_success trên order kèm dữ liệu. Web/App merchant có 2 cách để xác nhận kết quả thanh toán của đơn hàng:
- Cách 1: Web/App merchant nhận thông báo Webhook notification Bảo Kim gửi sang theo tham số "webhooks" trên đơn hàng (Khuyến nghị)
- Cách 2: Sau khi người dùng thanh toán, Bảo Kim redirect trình duyệt về url_success của đơn hàng kèm theo kết quả thanh toán, Web/App merchant xử lý kết quả trả về trên url_success (cách này có thể bị ảnh hưởng bởi lỗi đường truyền của khách hàng)
- Ngoài ra web/app merchant có thể gọi API Order Detail để chủ động kiểm tra trạng thái thanh toán của đơn hàng khi cần thiết.
Trong cả 2 cách trên, đơn hàng được coi là thanh toán thành công khi:
- trạng thái order "stat" == "c", và
- mã giao dịch thanh toán order "txn_id" có giá trị
- số tiền giao dịch (total_amount) khớp với giá trị đơn hàng phía merchant
Webhook Notification
Webhook notification là cơ chế thông báo cho Web/App merchant khi đơn hàng được thanh toán thành công thông qua HTTP POST request
Làm sao để nhận thông báo webhook notification?
- Khi gửi đơn hàng cần thanh toán sang bảo kim qua API Send Order, nhớ truyền tham số webhooks như mô tả
- Khi đơn hàng của bạn được thanh toán thành công Bảo Kim sẽ POST dữ liệu thanh toán theo url trên tham số webhooks của đơn hàng
Webhook notification sẽ gửi bao nhiêu lần?
- Gửi tối đa 10 lần, và
- Mỗi lần cách nhau 5 phút
- Dừng gửi khi nhận được kết quả trả về là chuỗi json có err_code = 0, vd {"err_code": "0", "message": "some message"} (giúp Bảo Kim xác định merchant đã nhận thông báo thành công)
Mô tả dữ liệu trên webhook notification
Method: POST
Header: Content-Type: application/json
Body (xem dữ liệu mẫu bên phải)
{
...."order": {
........"id": 45458,
........"user_id": "1000005",
........"mrc_order_id": "mrc_1543306400", //Mã đơn hàng duy nhất do merchant tạo và gửi sang
........"txn_id": "100000000", //Mã giao dịch thanh toán cho đơn hàng
........"ref_no": "TRF_10000000",
........"deposit_id": null,
........"merchant_id": null,
........"total_amount": "100000.00",
........"shipping_fee": "0.00",
........"tax_fee": "0.00",
........"mrc_fee": null,
........"description": "thanh toan don hang 1543306400",
........"url_success": "https:\/\/vnexpress.net\/",
........"url_cancel": null,
........"url_detail": null,
........"stat": "c", //Trạng thái thanh toán đơn hàng: "p" - đang xử lý / "c" - "hoàn thành"
........"payment_version": "4.0",
........"lang": "vi",
........"bpm_id": 0,
........"accept_qrpay": 0,
........"created_at": "2018-11-27 08:13:22",
........"updated_at": "2018-11-27 08:13:22"
....}
...."txn": {
........"id": 100000000,
........"user_id": 1000005,
........"account_id": 1001000079,
........"opening_balance": "1111968443.45",
........"amount": "10000.00",
........"balance": "1111978443.45",
........"opening_freeze_balance": "562387181.18",
........"freeze_amount": "0.00",
........"freeze_balance": "562387181.18",
........"ref_no": "TRF_10000000",
........"bank_ref_no": "vcb_1543390288",
........"type": null,
........"stat": 4,
........"description": "ut nap tien 1@bk.vn",
........"fee_amount": "0.00",
........"is_processed": 1,
........"src_des": null,
........"created_at": "2018-11-28 07:31:28",
........"updated_at": "2018-11-28 07:31:28"
....}
...."sign": "hmac_hash_xxxyyyzzz" //hash sử dụng hmac với thuật toán sha256 ký lên dữ liệu gửi đi nhằm đảm bảo tính toàn vẹn của dữ liệu
}
Các bước kiểm tra và xử lý khi nhận được webhook notification
- Kiểm tra tính toàn vẹn dữ liệu nhận được bằng cách kiểm tra tính chính xác của chữ ký sign như sau (Xem code mẫu PHP tab bên phải, dưới phần mô tả dữ liệu webhook):
- Sử dụng giá trị secret trong cặp key/secret trong API Key của bạn
- Sử dụng thuật toán hash_hmac với sha256, ký lên dữ liệu mà bạn nhận được (tất nhiên trừ trường $sign) => $yourSign
- So sánh chữ ký mà bạn tạo ra ($yourSign) với chữ ký mà bạn nhận được ($sign), nếu không giống nhau => dữ liệu không toàn vẹn
//Xác minh signature trên webhook với PHP
//Decode dữ liệu webhook notification nhận được từ Bảo Kim
$jsonWebhookData = '{"order":{order data},"txn":{txn data},"sign":"baokim sign"}';
$webhookData = json_decode($jsonWebhookData, true);
//Get và remove trường sign ra khỏi dữ liệu
$baokimSign = $webhookData['sign'];
unset($webhookData['sign']);
//Chuyển dữ liệu đã remove sign về lại dạng json và sử dụng thuật toán hash sha256 để tạo signature với secret key
$signData = json_encode($webhookData);
$secret = "9623ac03057e433f95d86cf4f3bef5cc";
$mySign = hash_hmac('sha256', $signData, $secret);
//So sánh chữ ký bạn tạo ra với chữ ký bảo kim gửi sang, nếu khớp thì verify thành công
if($baokimSign == $mySign)
echo "Signature is valid"
else
echo "Signature is invalid"
-
Kiểm tra trạng thái thanh toán đơn hàng, giao dịch thanh toán, số tiền thanh toán, hoàn thành đơn hàng
- Kiểm tra trạng thái đơn hàng đã thanh toán ($order->stat == 'c' //completed). Với giao dịch thanh toán từ thẻ tín dụng, có thể có ngoại lệ là trạng thái 'r' (Reviewing, xem mô tả dưới)
- Kiểm tra thông tin đơn hàng ($order) có đúng với thông tin đơn hàng trên web/app của bạn chưa
- Nếu các bước kiểm tra trên cho kết quả hoàn toàn đúng, bạn có thể chắc chắn rằng đơn hàng đã được thanh toán và có thể hoàn thành đơn hàng
-
Trả về chuỗi json có err_code = 0, vd {"err_code": "0", "message": "some message"} để Bảo Kim biết merchant đã nhận được thông báo và không tiếp tục gửi lại. Độ dài tối đa của dữ liệu trả về là 255 ký tự.
Dữ liệu trả về trên url_success
Nếu web/app merchant áp dụng xử lý kết quả thanh toán bằng cách 1 Webhook Notification, có thể bỏ qua việc xử lý dữ liệu trả về trên url_success và đơn giản là chỉ hiển thị trang thanh toán thành công cho khách hàng. Nếu không, hãy xác minh dữ liệu trả về trên url_success như sau.
Mô tả dữ liệu trên url_success
Name | Description |
---|---|
id | Request id (mã yêu cầu thanh toán Bảo Kim sinh ra) |
mrc_order_id | Mã đơn hàng duy nhất của merchant |
txn_id | Mã giao dịch thanh toán cho đơn hàng |
total_amount | Số tiền thanh toán đơn hàng |
stat | Trạng thái đơn hàng |
created_at | Thời gian ghi nhận đơn hàng |
updated_at | Thời gian ghi nhận thanh toán |
checksum | Chữ ký bảo mật dữ liệu (xem chi tiết dưới đây) |
Checksum được ký lên tham số truyền trên url_success sử dụng thuật toán hash sha256, với khóa bảo mật là secret key trong API key của quý khách. Cách xác minh checksum trên url_success xin hãy xem các bước và code mẫu ở tab bên phải.
$urlSuccess = 'https://example.com/baokim/payment-success?your_param=your_value&txn_id=10000000&mrc_order_id=yourOrderId&total_amount=20000&updated_at=2019-07-20+09%3A36%3A18&checksum=17c5f89c132c814e5e4647f9eb8398fd3dc0621fe57d1662b72878ee513ad413';
//1. load array các tham số trên url_success,
// loại bỏ trường checksum cũng như các tham số của merchant (không do bảo kim truyền)
$parts = parse_url($urlSuccess);
parse_str($parts['query'], $query);
$checksum = $query['checksum'];
unset($query['checksum']);
unset($query['your_param']);
//2. sort array các tham số theo key
ksort($query);
//3. Tạo string dữ liệu để ký từ array tham số đã sắp xếp
// theo định dạng key1=value1&key2=value2&...
$signData = http_build_query($query);
//4. Tạo và so sánh checksum
$myChecksum = hash_hmac('sha256', http_build_query($query), $secretKey);
if($checksum == $myChecksum)
echo "Checksum is valid"
else
echo "Checksum is invalid"
Liên kết ví
Liên kết user của ứng dụng bên thứ 3 với ví Bảo Kim phục vụ quản lý số dư, thực hiện đầy đủ các giao dịch của một ví điện tử ngay trên app của bên thứ 3.
Liên kết User <=> Ví
Quy trình liên kết ví
Mô tả quy trình
- User click liên kết ví với Bảo Kim từ phía web của Merchant.
- Merchant hiển thị Form nhập SĐT cho User.
- User submit SĐT
- Merchant gọi API Gửi yêu cầu liên kết ví kèm theo ?jwt=***
- Merchant sẽ nhận được response
ticket
- User sẽ nhận được
OTP
xác thực vào SĐT vừa gửi
- Merchant sẽ nhận được response
- Merchant hiển thị Form nhập OTP
- User submit OTP
- Merchant gọi API Xác thực liên kết kèm theo ?jwt=***
- Merchant sẽ nhận được response
linked_code
- Merchant sẽ nhận được response
- Merchant gọi API Xác thực linked_code kèm theo ?jwt=*** để xác thực linked_code
- Merchant sẽ nhận được response
user_id
(id tài khoản User của Bảo Kim) và mãtoken
(Token liên kết với ví Bảo Kim).
- Merchant sẽ nhận được response
- Merchant lưu lại token tương ứng với
user_id
Bảo Kim. - Kết thúc quy trình liên kết.
- Lưu ý: Jwt được generate theo cặp key/secret của Bảo Kim cấp riêng cho tính năng liên kết ví.
Quy trình huỷ liên kết ví
Mô tả quy trình
- User click huỷ liên kết ví với Bảo Kim từ phía web của Merchant.
- Merchant gọi API Gửi yêu cầu huỷ liên kết ví kèm theo ?jwt=*** và Headers: Wallet-Token = $token
- Merchant sẽ nhận được response
ticket
- User sẽ nhận được
OTP
xác thực vào SĐT vừa gửi
- Merchant sẽ nhận được response
- Merchant hiển thị Form nhập OTP
- User submit OTP
- Merchant gọi API Xác thực huỷ liên kết kèm theo ?jwt=*** và Headers: Wallet-Token = $token
- Merchant sẽ nhận được response
mrc_uuid
vàbk_uuid
- Merchant sẽ nhận được response
- Merchant xử lý xoá token tương ứng với
bk_uuid
Bảo Kim. - Kết thúc quy trình liên kết.
- Lưu ý: Jwt được generate theo cặp key/secret của Bảo Kim cấp riêng cho tính năng liên kết ví.
Demo liên kết ví Bảo Kim
Quy trình xác thực tài khoản
Mô tả quy trình
- Merchant check level của User, yêu cầu xác thực đối với User có level = 1 hoặc bằng 3.
- User click xác thực tài khoản từ phía web của Merchant.
- Merchant gọi API Gửi yêu cầu xác thực tài khoản kèm theo ?jwt=*** và Headers: Wallet-Token = $token
- Merchant sẽ nhận được
ticket
- Merchant sẽ nhận được
- Merchant hiển thị Form upload ảnh mặt trước, mặt sau của CMND/CCCD và ảnh cá nhân chụp cùng với CMND/CCCD.
- User upload các ảnh cần thiết
- Merchant gọi API Xác nhận yêu cầu xác thực tài khoản kèm theo ?jwt=*** và Headers: Wallet-Token = $token
- Merchant sẽ nhận được response thông tin user.
- Merchant hiển thị kết quả cho User.
- User nhận kết quả.
- Kết thúc quy trình liên kết.
- Lưu ý: Jwt được generate theo cặp key/secret của Bảo Kim cấp riêng cho tính năng liên kết ví.
Demo liên kết ví Bảo Kim
Lưu thẻ ATM lên ví
Quy trình
Mô tả quy trình
- User click tính năng liên kết thẻ ATM ngân hàng.
- Merchant gọi API Danh sách Phương thức thanh toán để lấy danh sách Ngân hàng, hiển thị danh sách cho User.
- User chọn Ngân hàng.
- Hiển thị màn hình xác nhận với các điều khoản.
- User click xác nhận.
- Merchant gọi API gửi yêu cầu liên kết thẻ.
- Merchant sẽ nhận được
$response
trong đó córesult
,dataKey
,napasKey
.
- Merchant sẽ nhận được
- Merchant tạo đoạn HTML như cột bên phải và nhúng vào ứng dụng web/mobile để hiển thị form nhập thông tin thẻ.
- Trong đó các tham số có giá trị như sau:
clientIP
=$response->data->client_id
deviceId
=$response->data->user_id
orderId
=$response->data->order->id
dataKey
=$response->data->dataKey
napasKey
=$response->data->napasKey
apiOperation
=$response->data->apiOperation
orderAmount
=$response->data->order->amount
orderCurrency
=$response->data->order->currency
orderReference
=$response->data->order->reference
//Code Js nhúng vào ứng dụng Web/Mobile:
<form id="merchant-form" action="https://yourwebsite.com/post_back_url?merchantId=BAOKIMICE" method="POST"></form>
<div id="napas-widget-container"></div>
<script type="text/javascript" id="napas-widget-script" src="https://dps-staging.napas.com.vn/api/restjs/resources/js/napas.hostedform.min.js"
merchantId="BAOKIMCE"
clientIP="client_ip"
deviceId="user_id"
environment="MobileApp"
cardScheme="AtmCard"
enable3DSecure="false"
orderId="order_id"
dataKey="dataKey"
napasKey="napasKey"
apiOperation="PAY_WITH_RETURNED_TOKEN"
orderAmount="10000"
orderCurrency="VND"
orderReference="reference"
channel="6014"
sourceOfFundsType="CARD"
language="vi">
</script>
- User nhập thông tin thẻ và Submit lên Bank.
- Thông tin thẻ Test:
- Xác thực trên trang Ngân hàng:
9704020000000016
-NGUYEN VAN A
-03/07
- Xác thực trên trang Napas:
9704000000000018
-NGUYEN VAN A
-03/07
OTP
là 'otp'.- Thẻ lỗi:
9704020000000018
- Sau khi thêm thẻ thành công, Website sẽ
redirect
về url Merchant truyền trênaction
ở mã code nhúng. - Merchant hiển thị kết quả.
- User nhận kết quả.
- Kết thúc quy trình.
Huỷ liên kết thẻ ATM
Quy trình
Mô tả quy trình
- User chọn thẻ, bấm huỷ liên kết.
- Merchant gọi API Yêu cầu huỷ liên kết thẻ ATM.
- User sẽ nhận được OTP về SĐT.
- Merchant sẽ nhận được
ticket
.
- Merchant hiển thị Form submit OTP.
- User submit OTP.
- Merchant gọi API Xác thực yêu cầu huỷ liên kết thẻ ATM.
- Merchant hiển thị kết quả.
- User nhận kết quả.
- Kết thúc quy trình.
Nạp tiền vào ví
Quy trình
Mô tả quy trình
- User click tính năng nạp tiền vào ví.
- Merchant gọi API Danh sách Thẻ liên kết với query_params conn_type = 2 để lấy danh sách thẻ Ngân hàng của User đã liên kết, hiển thị danh sách cho User.
- User chọn Thẻ, nhập số tiền và Submit.
- Merchant gọi API Nạp tiền vào ví.
- Merchant sẽ nhận được
$response
trong đó córesult
,dataKey
,napasKey
và các tham số cần thiết.
- Merchant sẽ nhận được
- Merchant tạo đoạn HTML như cột bên phải và nhúng vào ứng dụng web/mobile để hiển thị form nhập thông tin thẻ.
- Trong đó các tham số có giá trị như sau:
clientIP
=$response->data->client_id
deviceId
=$response->data->user_id
orderId
=$response->data->order->id
dataKey
=$response->data->dataKey
napasKey
=$response->data->napasKey
apiOperation
=$response->data->apiOperation
orderAmount
=$response->data->order->amount
orderCurrency
=$response->data->order->currency
orderReference
=$response->data->order_reference
//Code Js nhúng vào ứng dụng Web/Mobile:
<form id="merchant-form" action="https://yourwebsite.com/post_back_url?merchantId=BAOKIMICE" method="POST"></form>
<div id="napas-widget-container"></div>
<script type="text/javascript" id="napas-widget-script" src="https://dps-staging.napas.com.vn/api/restjs/resources/js/napas.hostedform.min.js"
merchantId="BAOKIMCE"
clientIP="client_ip"
deviceId="user_id"
environment="MobileApp"
cardScheme="AtmCard"
enable3DSecure="false"
orderId="order_id"
dataKey="dataKey"
napasKey="napasKey"
apiOperation="PAY_WITH_RETURNED_TOKEN"
orderAmount="10000"
orderCurrency="VND"
orderReference="reference"
channel="6014"
sourceOfFundsType="CARD"
language="vi">
</script>
- User nhập
OTP
xác nhận.OTP
là 'otp'.
- Sau khi thêm thẻ thành công, Website sẽ
redirect
về url Merchant truyền trênaction
ở mã code nhúng. - Merchant hiển thị kết quả.
- User nhận kết quả.
- Kết thúc quy trình.
Chuyển tiền ví => ví
Quy trình
Mô tả quy trình
- User chọn Chuyển tiền.
- Merchant hiển thị Form chuyển tiền.
- User nhập thông tin chuyển tiền (Người nhận/Số tiền/Mô tả) và Submit.
- Merchant gọi API Gửi yêu cầu chuyển tiền.
- Merchant nhận được
response
làticket
. - User sẽ nhận được mã OTP gửi về SĐT.
- Merchant nhận được
- Merchant hiển thị Form xác thực OTP.
- User nhập OTP và Submit.
- Merchant gọi API xác thực chuyển tiền.
- Merchant nhận được
response
bao gồmtransfer
là thông tin chuyển tiền,txn
là thông tin giao dịch của Bảo Kim.
- Merchant nhận được
- Merchant hiển thị Kết quả.
- User nhận kết quả.
- Kết thúc quy trình.
Rút tiền từ ví => bank
Quy trình
Mô tả quy trình
- User chọn Rút tiền
- Merchant gọi API Danh sách Thẻ/Tài khoản nhận tiền để lấy danh sách thẻ/tài khoản Ngân hàng của User đã thêm, hiển thị danh sách cho User.
- User chọn thẻ/tài khoản, nhập số tiền và Submit.
- Merchant gọi API Yêu cầu rút tiền.
- Merchant nhận được
response
làticket
. - User sẽ nhận được mã OTP gửi về SĐT.
- Merchant nhận được
- Merchant hiển thị Form xác thực OTP.
- User nhập OTP và Submit.
- Merchant gọi API xác thực rút tiền.
- Merchant nhận được
response
bao gồmwithdrawal
là thông tin lệnh rút tiền,txn
là thông tin giao dịch của Bảo Kim.
- Merchant nhận được
- Merchant hiển thị Kết quả.
- User nhận kết quả.
- Kết thúc quy trình.
Thêm tài khoản nhận tiền
Quy trình thêm tài khoản nhận tiền
- User chọn thêm mới tài khoản nhận tiền.
2.Merchant gọi API danh sách Ngân hàng để lấy danh sách Ngân hàng Bảo Kim hỗ trợ.
- Merchant nhận được
response
danh sách thông tin Ngân hàng.
- Merchant nhận được
- Merchant hiển thị danh sách Ngân hàng và Form nhập thông tin tài khoản nhận tiền.
- User chọn Ngân hàng, nhập thông tin tài khoản.
- Merchant gọi API thêm mới tài khoản Ngân hàng
- Merchant nhận được
response
thông tin tài khoản Ngân hàng lưu tại Bảo Kim.
- Merchant nhận được
- Merchant hiển thị kết quả.
- User nhận kết quả.
- Kết thúc quy trình.
Thanh toán qua ví
Quy trình
Mô tả quy trình
- User chọn Option thanh toán qua ví.
- Merchant gọi API gửi yêu cầu thanh toán qua ví
- Merchant nhận được
response
làticket
. - User nhận OTP gửi về SĐT
- Merchant nhận được
- Merchant hiển thị Form Nhập OTP.
- User nhập & submit OTP.
- Merchant gọi API xác thực OTP thanh toán từ ví
- Merchant nhận được
response
bao gồmtransfer
,txn
vàorder
- Merchant nhận được
- Merchant hiển thị kết quả dựa vào trạng thái
order
. - User nhận kết quả.
- Kết thúc quy trình.
Thanh toán qua thẻ liên kết
Quy trình
Mô tả quy trình
- User chọn Option Thanh toán bằng thẻ liên kết.
- Merchant gọi API Danh sách Thẻ liên kết với query_params conn_type = 2 để lấy danh sách thẻ Ngân hàng của User đã liên kết, hiển thị danh sách cho User.
- User chọn Thẻ, nhập số tiền và Submit.
- Merchant gọi API Gửi yêu cầu thanh toán từ thẻ Liên kết.
- Merchant sẽ nhận được
$response
trong đó córesult
,dataKey
,napasKey
và các tham số cần thiết.
- Merchant sẽ nhận được
- Merchant tạo đoạn HTML như cột bên phải và nhúng vào ứng dụng web/mobile để hiển thị form nhập thông tin thẻ.
- Trong đó các tham số có giá trị như sau:
clientIP
=$response->data->client_id
deviceId
=$response->data->user_id
orderId
=$response->data->order->id
dataKey
=$response->data->dataKey
napasKey
=$response->data->napasKey
apiOperation
=$response->data->apiOperation
orderAmount
=$response->data->order->amount
orderCurrency
=$response->data->order->currency
orderReference
=$response->data->order_reference
//Code Js nhúng vào ứng dụng Web/Mobile:
<form id="merchant-form" action="https://yourwebsite.com/post_back_url?merchantId=BAOKIMICE" method="POST"></form>
<div id="napas-widget-container"></div>
<script type="text/javascript" id="napas-widget-script" src="https://dps-staging.napas.com.vn/api/restjs/resources/js/napas.hostedform.min.js"
merchantId="BAOKIMCE"
clientIP="client_ip"
deviceId="user_id"
environment="MobileApp"
cardScheme="AtmCard"
enable3DSecure="false"
orderId="order_id"
dataKey="dataKey"
napasKey="napasKey"
apiOperation="PAY_WITH_RETURNED_TOKEN"
orderAmount="10000"
orderCurrency="VND"
orderReference="reference"
channel="6014"
sourceOfFundsType="CARD"
language="vi">
</script>
- User nhập
OTP
xác nhận.OTP
là 'otp'.
- Sau khi thêm thẻ thành công, Website sẽ
redirect
về url Merchant truyền trênaction
ở mã code nhúng. - Merchant kiểm tra kết quả đơn hàng bằng order_id nhận được ở bước 4, hiển thị kết quả.
- User nhận kết quả.
- Kết thúc quy trình.
Bảng mã lỗi
Hằng số/Const Mã /Code Mô tả/Description ERR_NONE 0 Thành công (không có lỗi) ERR_SYSTEM 1 Lỗi hệ thống ERR_VALIDATION 2 Lỗi validate dữ liệu/tham số ERR_OBJECT_NOT_FOUND 3 Lỗi không tìm thấy đối tượng (tài khoản/giao dịch/đơn hàng...) ERR_ACCOUNT_LOCKED 4 Lỗi tài khoản bị khóa ERR_UNAUTHORIZED 5 Lỗi không được phép thực hiện giao dịch (đăng nhập, xác thực 2FA lỗi) ERR_INVALID_AMOUNT 6 Lỗi số tiền giao dịch không chính xác ERR_DUPLICATED_ACTION 7 Lỗi giao dịch lặp (vd thanh toán 2 lần...) ERR_INTERNAL_SERVICE 8 Lỗi hệ thống nội bộ ERR_INSUFFICIENT_BALANCE 9 Lỗi số dư tài khoản không đủ thực hiện giao dịch ERR_EXCEED_MAX_DAILY_AMOUNT 10 Lỗi số tiền giao dịch vượt quá hạn mức ngày ERR_VERIFY_FAILED 11 Lỗi xác minh giao dịch ERR_CONFIG_FEE_NOT_FOUND 12 Lỗi cấu hình tính phí ERR_ACCOUNT_NOT_FOUND 13 Lỗi không tìm thấy tài khoản giao dịch ERR_AMOUNT_TOO_SMALL 14 Lỗi số tiền quá nhỏ so với hạn mức ERR_AMOUNT_TOO_BIG 15 Lỗi số tiền quá lớn so với hạn mức ERR_USER_NOT_VERIFIED 16 Lỗi user chưa xác thực tài khoản ERR_TRANSACTION_REFUNDED 18 Lỗi hoàn tiền lặp (khi thực hiện hoàn tiền) ERR_TRANSACTION_NOT_COMPLETE 17 Lỗi trạng thái giao dịch chưa hoàn thành ERR_BANK_ACCOUNT_EXISTED 19 Tài khoản Ngân hàng đã tồn tại trên hệ thống ERR_BANK_CARD_NOT_FOUND 20 Không tìm thấy thẻ Ngân hàng ERR_TRANSFER_ON_BANK 21 Lỗi chuyển tiền sang Thẻ ngân hàng ERR_BANK_ACCOUNT_NAME_NOT_MATCH 22 Tên Tài khoản ngân hàng không trùng với tên Ví ERR_BANK_ACCOUNT_NOT_FOUND 23 Không tìm thấy Tài khoản Ngân hàng ERR_OTHER 24 Lỗi khác (không xác định) ERR_REFUND_NOT_ALLOWED 25 Loại giao dịch không được hoàn tiền ERR_BANK_CARD_EXISTED 27 Thẻ Ngân hàng đã tồn tại trên hệ thống ERR_LINKED_USER_EXIST 47 Liên kết ví đã tồn tại ERR_MRC_NOT_FOUND 48 Không tìm thấy Merchant ERR_LINKED_CODE_INVALID 49 Mã xác thực liên kết không chính xác ERR_TICKET_FALSE 51 Ticket sai định dạng ERR_LINKED_TOKEN_INVALID 52 Token liên kết không hợp lệ ERR_LINKED_USER_VERIFIED 53 Liên kết đã được xác thực. Không thể thực hiện lại ERR_TICKET_EXPIRED 61 Ticket đã hết hạn. Vui lòng thực hiện lại ERR_LINKED_CODE_EXPIRED 62 Linked code đã hết hạn. Vui lòng thực hiện lại ERR_TOKEN_UNAUTHORIZATION 63 Token Unauthorization ERR_AUTHENTICATION_BANK_CARD 180 Lỗi xác thực thẻ
Account API
Các API về tài khoản
Account detail
[API Get chi tiết thông tin tài khoản ví Bảo Kim của user]
Example request:
curl -X GET -G "https://api.baokim.vn/payment/api/v4/account/detail"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/account/detail",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$response = $client->request("GET", "https://api.baokim.vn/payment/api/v4/account/detail", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": {
"id": 1001000079,
"user_id": 1000005,
"type": 1,
"balance": "1110852443.45",
"freeze_balance": "562387181.18",
"stat": 0,
"last_act_id": 27496,
"created_at": "2010-04-22 07:18:50",
"updated_at": "2018-07-02 00:28:59",
"info": {
"email": "example@gmail.com",
"phone": "84912061996",
"name": "BHD ABC",
"type": 1,
"stat": 1,
"lvl": 1,
"business_type": 1
}
}
}
HTTP Request
GET api/v4/account/detail
Bank API
Bank List
Danh sách ngân hàng Bảo Kim hỗ trợ, Web/App merchant có thể sử dụng API này để hiển thị danh sách Ngân hàng trên ứng dụng của mình
Example request:
curl -X GET -G "https://api.baokim.vn/payment/api/v4/bank/list"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/bank/list",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$options['query']['lb_available'] = 'OT83rKyVcCzmcvvH';
$options['query']['offset'] = 'aSyOKSb4VMlIS5iJ';
$options['query']['limit'] = 'dDqrvNYAliJYeoNm';
$response = $client->request("GET", "https://api.baokim.vn/payment/api/v4/bank/list", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"msg": "thành công",
"count": 1,
"data": [
{
"id": "105",
"name": "VPBank - Ngân hàng Việt Nam Thịnh Vượng",
"short_name": "VPBank",
"logo": "uploads\/banks\/vietcombank.png",
"lb_available": 0
},
{
"id": "87",
"name": "Techcombank - Ngân hàng Kỹ thương Việt Nam",
"short_name": "Techcombank",
"logo": "uploads\/banks\/techcombank.png",
"lb_available": 0
}
]
}
HTTP Request
GET api/v4/bank/list
Query Parameters
Parameter | Status | Description |
---|---|---|
lb_available | optional | Tìm theo danh sách ngân hàng hỗ trợ liên kết ví (1: hỗ trợ, 0: không hổ trợ) |
offset | optional | Lấy bản ghi từ |
limit | optional | Số bản ghi tối đa |
Bank Account API
APIs for managing Bank Accounts
Danh sách Tài khoản Ngân hàng
Example request:
curl -X GET -G "https://api.baokim.vn/payment/api/v4/bank-account/list"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/bank-account/list",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$response = $client->request("GET", "https://api.baokim.vn/payment/api/v4/bank-account/list", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": [
{
"id": 982,
"user_id": 1000005,
"bank_id": 1,
"holder": "Firzen Le",
"number": "xxxx xxxx xxxx 1111",
"branch": "Ha Noi",
"province_id": 31,
"is_default": 0,
"is_active": 1,
"verify_stat": "w",
"verify_branch": "u",
"description": null,
"created_at": "2017-09-21 04:14:53",
"updated_at": "2017-09-21 04:14:53"
}
]
}
HTTP Request
GET api/v4/bank-account/list
API thêm mới tài khoản Ngân hàng
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/bank-account/create" -d "user_id"="13" \
-d "bank_id"="11" \
-d "holder"="Z9ZBCVjZewCLfv9C" \
-d "number"="RJzG4wf4CKubCszE" \
-d "branch"="fpFrWf6Ly1pED6DO" \
-d "province_id"="susNzcNNxHpG9ylP" \
-d "is_active"="18" \
-d "description"="Cc4A2XoGQsVzsZi5"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/bank-account/create",
"method": "POST",
"data": {
"user_id": 13,
"bank_id": 11,
"holder": "Z9ZBCVjZewCLfv9C",
"number": "RJzG4wf4CKubCszE",
"branch": "fpFrWf6Ly1pED6DO",
"province_id": "susNzcNNxHpG9ylP",
"is_active": 18,
"description": "Cc4A2XoGQsVzsZi5"
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['user_id'] = "13";
$payload['bank_id'] = "11";
$payload['holder'] = "Z9ZBCVjZewCLfv9C";
$payload['number'] = "RJzG4wf4CKubCszE";
$payload['branch'] = "fpFrWf6Ly1pED6DO";
$payload['province_id'] = "susNzcNNxHpG9ylP";
$payload['is_active'] = "18";
$payload['description'] = "Cc4A2XoGQsVzsZi5";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/bank-account/create", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": {
"user_id": 1016006,
"bank_id": "1",
"holder": "Nguyen Van Dong",
"number": "07110000216088",
"branch": null,
"province_id": null,
"description": null,
"is_active": "1",
"updated_at": "2019-03-20 10:03:23",
"created_at": "2019-03-20 10:03:23",
"id": 990
}
}
HTTP Request
POST api/v4/bank-account/create
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
user_id | integer | required | Mã tài khoản Bảo kim |
bank_id | integer | required | Mã ngân hàng |
holder | string | required | Chủ Tài khoản |
number | string | required | Số Tài khoản |
branch | string | optional | Chi nhánh |
province_id | string | optional | ID Tỉnh thành |
is_active | integer | required | Trạng thái verification |
description | string | optional | Ghi chú |
Bank Card API
APIs for managing Bank Cards
Bank Card List
[List danh sách Thẻ Ngân hàng của user]
Example request:
curl -X GET -G "https://api.baokim.vn/payment/api/v4/bank-card/list"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/bank-card/list",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$options['query']['conn_type'] = 'u1FxZjuEWrMZzrYP';
$response = $client->request("GET", "https://api.baokim.vn/payment/api/v4/bank-card/list", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": [
{
"id": "ID thẻ, sử dụng khi thực hiện giao dịch nạp, rút về thẻ",
"user_id": 1000005,
"bank_id": 131,
"deposit_bpm_id": 154,
"withdraw_bpm_id": 155,
"card_type": null,
"owner_name": "Firzen Le",
"short_name": null,
"code": "số thẻ",
"cvv_code": null,
"token": null,
"expiration_date": "12-12",
"verification": 1,
"alias": "ABBank - Ngân hàng An Bình - 2661",
"created_at": "2017-08-30 09:15:55",
"updated_at": "2017-08-30 09:16:24"
}
]
}
HTTP Request
GET api/v4/bank-card/list
Query Parameters
Parameter | Status | Description |
---|---|---|
conn_type | optional | Loại thẻ (1: thẻ rút tiền, 2: thẻ liên kết) |
Bank Payment API
Bank Payment Method List
Danh sách phương thức thanh toán từ các ngân hàng Bảo Kim hỗ trợ, Web/App merchant có thể sử dụng API này để hiển thị phương thức thanh toán trên ứng dụng của mình Danh sách này được phân loại theo trường "type" như sau:
- type = 0: thanh toán từ ví Bảo Kim
- type = 1: thẻ ATM online các ngân hàng
- type = 2: thẻ visa/master
- type = 3: Chuyển khoản
- type = 13: QR code
- type = 16: Tài khoản ảo
Example request:
curl -X GET -G "https://api.baokim.vn/payment/api/v4/bpm/list"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/bpm/list",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$response = $client->request("GET", "https://api.baokim.vn/payment/api/v4/bpm/list", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 76,
"data": [
{
"id": 9,
"name": "Thẻ ATM DongA Bank",
"bank_id": 82,
"type": 1,
"complete_time": "Ngay lập tức",
"bank_name": "DongA Bank - Ngân hàng Đông Á",
"bank_short_name": "DongA Bank",
"bank_logo": "https:\/\/cdn.baokim.vn\/public\/uploads\/banks\/82.png"
},
{
"id": 40,
"name": "Thẻ ATM Vietinbank",
"bank_id": 81,
"type": 1,
"complete_time": "ngay lập tức",
"bank_name": "VietinBank - Ngân hàng Công Thương",
"bank_short_name": "Vietin Bank",
"bank_logo": "https:\/\/cdn.baokim.vn\/public\/uploads\/banks\/81.png"
}
]
}
HTTP Request
GET api/v4/bpm/list
Fee API
Tính phí GD
Tính phí GD cho user
Example request:
curl -X GET -G "https://api.baokim.vn/payment/api/v4/txn/calculate-fee"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/txn/calculate-fee",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$options['query']['txn_type'] = 'P0QyePA917oNwIBe';
$options['query']['amount'] = 'iSePPpAI41XJDcmz';
$response = $client->request("GET", "https://api.baokim.vn/payment/api/v4/txn/calculate-fee", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"msg": "thành công",
"count": 1,
"data": {
"fee_amount": 50000,
"fee_payer": 1
}
}
HTTP Request
GET api/v4/txn/calculate-fee
Query Parameters
Parameter | Status | Description |
---|---|---|
txn_type | required | Loại GD |
amount | required | Số tiền nạp (do mức phí có thể bị ảnh hưởng bởi số tiền nạp). |
Tính phí thanh toán
[Tính toán mức phí ngân hàng theo phương thức và số tiền thanh toán]
Example request:
curl -X GET -G "https://api.baokim.vn/payment/api/v4/bpm/calculate-fee"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/bpm/calculate-fee",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$options['query']['bpm_id'] = 'PQxn2M0elG5ITejg';
$options['query']['amount'] = 'H18ofWkqqsX1sbS0';
$response = $client->request("GET", "https://api.baokim.vn/payment/api/v4/bpm/calculate-fee", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": {
"id": 8,
"user_id": 1000005,
"bpm_id": 128,
"amount_from": "111.00",
"amount_to": "1000000.00",
"txn_type": 18,
"conn_type": 0,
"fix_fee": "1.00",
"percent_fee": "1.00",
"min_fee": "0.00",
"max_fee": "0.00",
"fee_currency_code": "USD",
"active": 1,
"created_at": null,
"updated_at": "2019-01-23 03:42:16",
"fee_amount": 5001
}
}
HTTP Request
GET api/v4/bpm/calculate-fee
Query Parameters
Parameter | Status | Description |
---|---|---|
bpm_id | required | ID phương thức thanh toán |
amount | required | Số tiền nạp (do mức phí có thể bị ảnh hưởng bởi số tiền nạp) |
Liên kết ví API
Link ATM Card
[API liên kết thẻ ngân hàng]
Headers: Wallet-Token : $token
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/linked-wallet/linked-atm-card" -d "bpm_id"="17"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/linked-atm-card",
"method": "POST",
"data": {
"bpm_id": 17
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['bpm_id'] = "17";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/linked-wallet/linked-atm-card", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": {
"apiOperation": "DATA_KEY",
"order": {
"amount": "10000",
"currency": "VND",
"id": "BK_1586849701",
"reference": "CASHIN1330642"
},
"result": "SUCCESS",
"dataKey": "cT0IN6xSIuqwRg5M8ZuyUVN\/G7fOpEz3TjPqZMvJn5Ydi+zqGS2T6B1XwpVKrh3+SzxyGchCv5lcjkQKfSJs27j3HcWwPqD5HGkecpEs87EoMg\/XUD2M3XWgQzM8P9dP6WKyR9EnoBhuPhkb5eCCiqqJxwZWxBa2rtKTw66nkxno3GzmrluzR1+KV5mUPyGZ7KHccptdkmDmIuqi4dPfUF\/xPtx99lANT1qDwYoDNcBt8Pnd22IxWOrxHTyEqTQBIbnDxjXIaX5RMuUXxMHk7MSeAMbRPSltDfG2mENewCORWCLXCCi1IB3hslN9buFpyevaBAa5o0UcTgS9EvGTcYeyCiW4EdelyN1hWeYOzNvZNTfCwzKdbDAuyRvxqC\/L0W8CGk4npgh60xPptfSRdDQ0W7xeJwNWptxGraO6fdEmhalXaPJjXK+br5tBWWBTea8\/RG7++XHuhe\/DfeJnMw==",
"napasKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArbP6iFl0Z9pDHv5ni\/fhl4ME6AfP16E5zmrHYftaBlcvq1bWRwk1TH23OrYQ6n6jEGIbmrVXzIM00lk723\/ZHtvbyZld8r5TcEh5M+h\/jIu3\/J9gqNYGTo9jLJ0DvRdSfzbDWJqPImPfcGJDRPTrEtckqmd8HvkU6J3MCPrg0IOGTYplUmw6DZ25g1SpBSb1CAWGqP36nqyxNZ4hNJ08agHQbRc\/ICHUb\/8+\/UjDETX96SYVn+GBKbrMM\/NcgiJV7UXbEmQ9OEiM3BbI5srhCOt0oYoCp0sJcpLcLbRlpdC7\/nV44KPty1rkZ32KlBufz3UVggXpHPz0k0yxYTvl\/wIDAQAB:MIICtTCCAZ0CBgFoko89+DANBgkqhkiG9w0BAQUFADAeMRwwGgYDVQQDExNUZXN0IENBIENlcnRpZmljYXRlMB4XDTE5MDEyODAzNDQ0N1oXDTE5MDEyOTAzNDQ0N1owHjEcMBoGA1UEAxMTVGVzdCBDQSBDZXJ0aWZpY2F0ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK2z+ohZdGfaQx7+Z4v34ZeDBOgHz9ehOc5qx2H7WgZXL6tW1kcJNUx9tzq2EOp+oxBiG5q1V8yDNNJZO9t\/2R7b28mZXfK+U3BIeTPof4yLt\/yfYKjWBk6PYyydA70XUn82w1iajyJj33BiQ0T06xLXJKpnfB75FOidzAj64NCDhk2KZVJsOg2duYNUqQUm9QgFhqj9+p6ssTWeITSdPGoB0G0XPyAh1G\/\/Pv1IwxE1\/ekmFZ\/hgSm6zDPzXIIiVe1F2xJkPThIjNwWyObK4QjrdKGKAqdLCXKS3C20ZaXQu\/51eOCj7cta5Gd9ipQbn891FYIF6Rz89JNMsWE75f8CAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAFXK48p71S87EmrnCm5Yvv42Oxzh0B18\/q4jn891xS1abFRkW2jdCvpc3IUQL6gy+JFQcY2NSaLhIYgBafmcngiBFt4kkTqUuwSdIWudl3jYkO58SOYKdxW8jbXM5KwTujpb0gYBpf1u5828RmEq6YEog\/yx\/hYQOFQlfIBBZFNmUJ7U5TDCFL2wT5MqPg2cfb1DirveD3sLSIUc90IJM3eUXfzXqkwdrCKDZRSuV3TMHChi1IRio2fg7zesi9HliFueaekkvynnwXoG41LKaMSBMM\/Mdrb2tm29jVYnlYJ8Coj+dOjWhU2y83dFi5DGr8a3ftWOc+rEz2zlOUKRF7Q==",
"user_id": 1000005,
"client_ip": "118.70.233.72"
}
}
HTTP Request
POST api/v4/linked-wallet/linked-atm-card
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
bpm_id | integer | required | ID Phương thức thanh toán |
Top Up Card
[API nạp tiền vào ví]
Headers: Wallet-Token : $token
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/linked-wallet/topup-wallet" -d "amount"="17" \
-d "card_id"="2" \
-d "fee_amount"="9" \
-d "bank_fee_amount"="4"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/topup-wallet",
"method": "POST",
"data": {
"amount": 17,
"card_id": 2,
"fee_amount": 9,
"bank_fee_amount": 4
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['amount'] = "17";
$payload['card_id'] = "2";
$payload['fee_amount'] = "9";
$payload['bank_fee_amount'] = "4";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/linked-wallet/topup-wallet", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": {
"apiOperation": "PURCHASE_OTP",
"merchantId": "BAOKIMCE",
"order": {
"amount": "100550",
"creationTime": "2020-04-14T16:04:19.589Z",
"currency": "VND",
"id": "ORD_BK_1586855062"
},
"response": {
"acquirerCode": "11",
"gatewayCode": "PENDING_FOR_OTP"
},
"result": "SUCCESS",
"sourceOfFunds": {
"provided": {
"card": {
"brand": "SML",
"nameOnCard": "NGUYEN VAN A",
"issueDate": "0307",
"number": "970400xxxxxx0018",
"scheme": "OTHERS"
}
},
"type": "CARD"
},
"transaction": {
"acquirer": {
"id": "835640836",
"transactionId": "835640836"
},
"amount": "100550",
"currency": "VND",
"id": "1205628",
"type": "PAYMENT"
},
"version": "1",
"channel": "1234",
"dataKey": "cT0IN6xSIuqwRg5M8ZuyUVN\/G7fOpEz3TjPqZMvJn5Ydi+zqGS2T6B1XwpVKrh3+SzxyGchCv5lcjkQKfSJs2788Ogjmro4SrpI46q+TIUxXdoSHnVCt7\/Bc3yiuKxoIM8wuGVOiOHC\/ubQzF1z7kqZwLE0yfhVy3No64aRSJ4ps509SwfK4AFpLve+XZHUMh1P6dwjz6\/sWhL0jainf+pqZu2ByS9WagIVL8HjnZKRif0R6iyi2kpZvmFoP9AekFdSfILFQ58tGeSYgHjcKUIc+5OJtrxT7FceE4Dgqr7IqJXQzcjZjtBGyST595dGcVqeuJfDy6tSMqhptIRDMPyLlAlzVi8dEJb0+X4jVEs3kRTIagGf1R0yA01YDJf41Jao83k0YJxVTgxBuSvlLhAV9LEx7d1GzwhDSOkDRDg\/pyErtBXNznx5Vr6IfOKYv+JPz030U3WZIU5SGKXbsfQ==",
"napasKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArbP6iFl0Z9pDHv5ni\/fhl4ME6AfP16E5zmrHYftaBlcvq1bWRwk1TH23OrYQ6n6jEGIbmrVXzIM00lk723\/ZHtvbyZld8r5TcEh5M+h\/jIu3\/J9gqNYGTo9jLJ0DvRdSfzbDWJqPImPfcGJDRPTrEtckqmd8HvkU6J3MCPrg0IOGTYplUmw6DZ25g1SpBSb1CAWGqP36nqyxNZ4hNJ08agHQbRc\/ICHUb\/8+\/UjDETX96SYVn+GBKbrMM\/NcgiJV7UXbEmQ9OEiM3BbI5srhCOt0oYoCp0sJcpLcLbRlpdC7\/nV44KPty1rkZ32KlBufz3UVggXpHPz0k0yxYTvl\/wIDAQAB:MIICtTCCAZ0CBgFoko89+DANBgkqhkiG9w0BAQUFADAeMRwwGgYDVQQDExNUZXN0IENBIENlcnRpZmljYXRlMB4XDTE5MDEyODAzNDQ0N1oXDTE5MDEyOTAzNDQ0N1owHjEcMBoGA1UEAxMTVGVzdCBDQSBDZXJ0aWZpY2F0ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK2z+ohZdGfaQx7+Z4v34ZeDBOgHz9ehOc5qx2H7WgZXL6tW1kcJNUx9tzq2EOp+oxBiG5q1V8yDNNJZO9t\/2R7b28mZXfK+U3BIeTPof4yLt\/yfYKjWBk6PYyydA70XUn82w1iajyJj33BiQ0T06xLXJKpnfB75FOidzAj64NCDhk2KZVJsOg2duYNUqQUm9QgFhqj9+p6ssTWeITSdPGoB0G0XPyAh1G\/\/Pv1IwxE1\/ekmFZ\/hgSm6zDPzXIIiVe1F2xJkPThIjNwWyObK4QjrdKGKAqdLCXKS3C20ZaXQu\/51eOCj7cta5Gd9ipQbn891FYIF6Rz89JNMsWE75f8CAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAFXK48p71S87EmrnCm5Yvv42Oxzh0B18\/q4jn891xS1abFRkW2jdCvpc3IUQL6gy+JFQcY2NSaLhIYgBafmcngiBFt4kkTqUuwSdIWudl3jYkO58SOYKdxW8jbXM5KwTujpb0gYBpf1u5828RmEq6YEog\/yx\/hYQOFQlfIBBZFNmUJ7U5TDCFL2wT5MqPg2cfb1DirveD3sLSIUc90IJM3eUXfzXqkwdrCKDZRSuV3TMHChi1IRio2fg7zesi9HliFueaekkvynnwXoG41LKaMSBMM\/Mdrb2tm29jVYnlYJ8Coj+dOjWhU2y83dFi5DGr8a3ftWOc+rEz2zlOUKRF7Q==",
"user_id": 1000005,
"client_ip": "118.70.233.72",
"deposit_id": 125643
}
}
HTTP Request
POST api/v4/linked-wallet/topup-wallet
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
amount | integer | required | Số tiền nạp |
card_id | integer | required | ID thẻ đã lưu |
fee_amount | integer | optional | phí bảo kim |
bank_fee_amount | integer | optional | phí ngân hàng |
Gửi yêu cầu giao dịch chuyển tiền
Headers: Wallet-Token: $wallet_token
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/linked-wallet/request-transfer" -d "to_user"="6mU1AzW1JBanWRTT" \
-d "amount"="2726" \
-d "description"="BWF87hF0qpmU9Qdr" \
-d "fee_amount"="15" \
-d "bank_fee_amount"="16" \
-d "verify_transaction_by"="QBIT5sHSesgqiiG3"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/request-transfer",
"method": "POST",
"data": {
"to_user": "6mU1AzW1JBanWRTT",
"amount": 2726,
"description": "BWF87hF0qpmU9Qdr",
"fee_amount": 15,
"bank_fee_amount": 16,
"verify_transaction_by": "QBIT5sHSesgqiiG3"
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['to_user'] = "6mU1AzW1JBanWRTT";
$payload['amount'] = "2726";
$payload['description'] = "BWF87hF0qpmU9Qdr";
$payload['fee_amount'] = "15";
$payload['bank_fee_amount'] = "16";
$payload['verify_transaction_by'] = "QBIT5sHSesgqiiG3";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/linked-wallet/request-transfer", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"msg": [],
"count": 0,
"data": {
"ticket": "eyNmVESFNPcHdKK3JMdEQ5WDZxUmZQb3BNcjJ6N04rZWlXeVNwekViTzF4UWJTNk02VldzRzdBK3BKeU9ZdkFsekh0YXF5d0lCZlZDb3NYaUpoZmJsb3c9PQ=="
}
}
HTTP Request
POST api/v4/linked-wallet/request-transfer
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
to_user | string | required | Người nhận (email/phone) |
amount | number | required | Số tiền |
description | string | required | Mô tả |
fee_amount | integer | optional | phí bảo kim |
bank_fee_amount | integer | optional | phí ngân hàng |
verify_transaction_by | string | optional | Xác nhận giao dich. Lựa chọn: otp(mặc định) hoặc transaction_password |
Xác nhận OTP chuyển tiền
Headers: Wallet-Token: $wallet_token
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/linked-wallet/confirm-transfer" -d "otp"="67.945796146" \
-d "transaction_password"="639.8312" \
-d "ticket"="PTxIlZXvc1GqJVdu"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/confirm-transfer",
"method": "POST",
"data": {
"otp": 67.945796146,
"transaction_password": 639.8312,
"ticket": "PTxIlZXvc1GqJVdu"
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['otp'] = "67.945796146";
$payload['transaction_password'] = "639.8312";
$payload['ticket'] = "PTxIlZXvc1GqJVdu";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/linked-wallet/confirm-transfer", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"msg": [],
"count": 0,
"data": {
"transfer": {
"from_account_id": 1001033358,
"to_account_id": 1001033402,
"amount": "10000",
"description": "Mo ta chuyen tien",
"fee_from": 0,
"fee_to": 100,
"stat": 1,
"order_id": null,
"updated_at": "2020-04-20 10:36:14",
"created_at": "2020-04-20 10:36:14",
"id": 1993
},
"txn": {
"user_id": 1330642,
"account_id": 1001033358,
"amount": -10000,
"fee_amount": 0,
"fee_display": 100,
"description": "Mo ta chuyen tien",
"ref_no": "TRF_1993",
"stat": 4,
"type": 5,
"src_des": "haumv174@gmail.com",
"updated_at": "2020-04-20 10:36:14",
"created_at": "2020-04-20 10:36:14",
"id": 59291,
"mrc_order_id": null,
"total_amount": null
}
}
}
HTTP Request
POST api/v4/linked-wallet/confirm-transfer
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
otp | number | optional | Mã otp |
transaction_password | number | required | Mật khẩu giao dịch |
ticket | string | required | Mã ticket |
Gửi yêu cầu giao dịch rút tiền
Headers: Wallet-Token: $wallet_token
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/linked-wallet/request-withdrawal" -d "card_id"="14" \
-d "bank_account_id"="14" \
-d "amount"="787640773.86626" \
-d "description"="DDe3c9QZOdB3q3p9" \
-d "type"="12" \
-d "fee_amount"="2" \
-d "bank_fee_amount"="18"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/request-withdrawal",
"method": "POST",
"data": {
"card_id": 14,
"bank_account_id": 14,
"amount": 787640773.866263,
"description": "DDe3c9QZOdB3q3p9",
"type": 12,
"fee_amount": 2,
"bank_fee_amount": 18
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['card_id'] = "14";
$payload['bank_account_id'] = "14";
$payload['amount'] = "787640773.86626";
$payload['description'] = "DDe3c9QZOdB3q3p9";
$payload['type'] = "12";
$payload['fee_amount'] = "2";
$payload['bank_fee_amount'] = "18";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/linked-wallet/request-withdrawal", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"msg": [],
"count": 0,
"data": {
"ticket": "eyNmVESFNPcHdKK3JMdEQ5WDZxUmZQb3BNcjJ6N04rZWlXeVNwekViTzF4UWJTNk02VldzRzdBK3BKeU9ZdkFsekh0YXF5d0lCZlZDb3NYaUpoZmJsb3c9PQ=="
}
}
HTTP Request
POST api/v4/linked-wallet/request-withdrawal
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
card_id | integer | optional | required_without:bank_account_id ID Tài khoản Nhận tiền |
bank_account_id | integer | optional | required_without:card_id ID Thẻ Nhận tiền |
amount | number | required | Số tiền |
description | string | required | Mô tả |
type | integer | required | 0: Tài khoản, 1: Thẻ |
fee_amount | integer | optional | phí bảo kim |
bank_fee_amount | integer | optional | phí ngân hàng |
Xác nhận OTP rút tiền
Headers: Wallet-Token: $wallet_token
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/linked-wallet/confirm-withdrawal" -d "otp"="12197146.4101" \
-d "ticket"="XG6I3uQ5MRBSKLpz"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/confirm-withdrawal",
"method": "POST",
"data": {
"otp": 12197146.4101,
"ticket": "XG6I3uQ5MRBSKLpz"
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['otp'] = "12197146.4101";
$payload['ticket'] = "XG6I3uQ5MRBSKLpz";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/linked-wallet/confirm-withdrawal", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"msg": [],
"count": 0,
"data": {
"withdrawal": {
"user_id": 1000005,
"account_id": 1001000079,
"card_id": 475,
"description": "rut tien ve the vcb",
"stat": 6,
"amount": "10000",
"fee_amount": 50000,
"net_amount": -40000,
"updated_at": "2018-12-18 05:31:15",
"created_at": "2018-12-18 05:31:15",
"id": 454
},
"txn": {
"user_id": 1000005,
"account_id": 1001000079,
"amount": -60000,
"fee_amount": 50000,
"fee_display": 50000,
"description": "rut tien ve the vcb",
"ref_no": 454,
"stat": 4,
"updated_at": "2018-12-18 05:31:15",
"created_at": "2018-12-18 05:31:15",
"id": 27815
}
}
}
HTTP Request
POST api/v4/linked-wallet/confirm-withdrawal
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
otp | number | required | Mã otp |
ticket | string | required | Mã ticket |
Thêm thẻ/tài khoản nhận tiền
Headers: Wallet-Token: $wallet_token
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/linked-wallet/add-withdrawal-option" -d "bank_id"="20063474.7188" \
-d "number"="0" \
-d "type"="1732.13928"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/add-withdrawal-option",
"method": "POST",
"data": {
"bank_id": 20063474.7188,
"number": 0,
"type": 1732.13928
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['bank_id'] = "20063474.7188";
$payload['number'] = "0";
$payload['type'] = "1732.13928";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/linked-wallet/add-withdrawal-option", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"msg": [],
"count": 0,
"data": {
"user_id": 1330642,
"bank_id": "117",
"number": "9704060129837294",
"own_name": "NGUYEN VAN NAPAS TEST ONLINE IBFT 247 VN",
"type": "1",
"withdraw_bpm_id": 184,
"stat": 0
}
}
HTTP Request
POST api/v4/linked-wallet/add-withdrawal-option
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
bank_id | number | required | Id Ngân hàng |
number | number | required | Số thẻ/Số tài khoản |
type | number | required | 0: Tài khoản, 1: Thẻ |
Danh sách thẻ/tài khoản nhận tiền
Headers: Wallet-Token: $wallet_token
Example request:
curl -X GET -G "https://api.baokim.vn/payment/api/v4/linked-wallet/get-list-withdrawal-option"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/get-list-withdrawal-option",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$response = $client->request("GET", "https://api.baokim.vn/payment/api/v4/linked-wallet/get-list-withdrawal-option", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"msg": [],
"count": 0,
"data": {
"account_type": [
{
"id": 927,
"bank_id": 110,
"ownName": "Firzen Le",
"number": "123123 xxx xxx 3123",
"stat": 0
},
{
"id": 928,
"bank_id": 110,
"ownName": "Firzen Le",
"number": "123123 xxx xxx 1231",
"stat": 0
},
{
"id": 929,
"bank_id": 110,
"ownName": "Firzen Le",
"number": "123123 xxx xxx 3123",
"stat": 0
}
],
"card_type": [
{
"id": 731,
"bank_id": 18,
"ownName": "LE DUC DANG",
"number": "970436 xxx xxx 5014",
"stat": 1
},
{
"id": 732,
"bank_id": 18,
"ownName": "LE DUC DANG",
"number": "970411 xxx xxx 2096",
"stat": 1
},
{
"id": 733,
"bank_id": 18,
"ownName": "LE DUC DANG",
"number": "970411 xxx xxx 2180",
"stat": 1
}
]
}
}
HTTP Request
GET api/v4/linked-wallet/get-list-withdrawal-option
API Chi tiết giao dịch nạp tiền
Headers: Wallet-Token: $wallet_token
Example request:
curl -X GET -G "https://api.baokim.vn/payment/api/v4/linked-wallet/get-txn-detail"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/get-txn-detail",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$response = $client->request("GET", "https://api.baokim.vn/payment/api/v4/linked-wallet/get-txn-detail", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"msg": [],
"count": 0,
"data": {
"id": 59781,
"user_id": 1991990,
"account_id": 1001033883,
"opening_balance": "10019900.00",
"amount": "9000000.00",
"balance": "19019900.00",
"opening_freeze_balance": "0.00",
"freeze_amount": "0.00",
"freeze_balance": "0.00",
"ref_no": "DEP_1206321",
"bank_ref_no": "835643443",
"type": 1,
"stat": 4,
"description": null,
"fee_amount": "0.00",
"fee_display": "100760.00",
"is_processed": 1,
"src_des": "Vietcombank",
"encrypted_id": null,
"deposit_id": 1206321,
"created_at": "2020-04-24 00:39:11",
"updated_at": "2020-04-24 00:39:11",
"mrc_order_id": null,
"total_amount": null
}
}
HTTP Request
GET api/v4/linked-wallet/get-txn-detail
Gửi yêu cầu thanh toán qua ví
Headers: Wallet-Token: $wallet_token
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/linked-wallet/request-payment-by-wallet" -d "mrc_order_id"="WHfN9cMazzCyE2T0" \
-d "amount"="4317768.1" \
-d "description"="yENLkCTvYgMootES" \
-d "fee_amount"="6" \
-d "bank_fee_amount"="17" \
-d "verify_transaction_by"="Dud0RTsmWFh7Zd7N"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/request-payment-by-wallet",
"method": "POST",
"data": {
"mrc_order_id": "WHfN9cMazzCyE2T0",
"amount": 4317768.1,
"description": "yENLkCTvYgMootES",
"fee_amount": 6,
"bank_fee_amount": 17,
"verify_transaction_by": "Dud0RTsmWFh7Zd7N"
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['mrc_order_id'] = "WHfN9cMazzCyE2T0";
$payload['amount'] = "4317768.1";
$payload['description'] = "yENLkCTvYgMootES";
$payload['fee_amount'] = "6";
$payload['bank_fee_amount'] = "17";
$payload['verify_transaction_by'] = "Dud0RTsmWFh7Zd7N";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/linked-wallet/request-payment-by-wallet", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"msg": [],
"count": 0,
"data": {
"ticket": "eyNmVESFNPcHdKK3JMdEQ5WDZxUmZQb3BNcjJ6N04rZWlXeVNwekViTzF4UWJTNk02VldzRzdBK3BKeU9ZdkFsekh0YXF5d0lCZlZDb3NYaUpoZmJsb3c9PQ=="
}
}
HTTP Request
POST api/v4/linked-wallet/request-payment-by-wallet
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
mrc_order_id | string | required | Mã đơn hàng |
amount | number | required | Số tiền |
description | string | required | Mô tả đơn hàng |
fee_amount | integer | optional | phí bảo kim |
bank_fee_amount | integer | optional | phí ngân hàng |
verify_transaction_by | string | optional | Xác nhận giao dich. Lựa chọn: otp(mặc định) hoặc transaction_password |
Xác nhận OTP thanh toán qua ví
Headers: Wallet-Token: $wallet_token
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/linked-wallet/confirm-payment-by-wallet" -d "otp"="612.178" \
-d "ticket"="J8j4N7emVqQXsjpt"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/confirm-payment-by-wallet",
"method": "POST",
"data": {
"otp": 612.178,
"ticket": "J8j4N7emVqQXsjpt"
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['otp'] = "612.178";
$payload['ticket'] = "J8j4N7emVqQXsjpt";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/linked-wallet/confirm-payment-by-wallet", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"msg": [],
"count": 0,
"data": {
"transfer": {
"from_account_id": 1001033358,
"to_account_id": 1001033402,
"amount": "10000",
"description": "",
"fee_from": 0,
"fee_to": 100,
"stat": 1,
"order_id": null,
"updated_at": "2020-04-20 10:36:14",
"created_at": "2020-04-20 10:36:14",
"id": 1993
},
"txn": {
"user_id": 1330642,
"account_id": 1001033358,
"amount": -10000,
"fee_amount": 0,
"fee_display": 100,
"description": "",
"ref_no": "TRF_1993",
"stat": 4,
"type": 5,
"src_des": "haumv174@gmail.com",
"updated_at": "2020-04-20 10:36:14",
"created_at": "2020-04-20 10:36:14",
"id": 59291,
"mrc_order_id": null,
"total_amount": null
},
"order": {
"id": 61442,
"user_id": 1000005,
"mrc_order_id": "Payment_wallet_01",
"txn_id": 59291,
"ref_no": null,
"deposit_id": null,
"merchant_id": null,
"total_amount": "100000.00",
"shipping_fee": "0.00",
"tax_fee": "0.00",
"mrc_fee": null,
"description": "Thanh toann tu vi",
"items": null,
"url_success": null,
"url_cancel": null,
"url_detail": null,
"stat": "c",
"payment_version": "4.0",
"lang": "vi",
"bpm_id": 0,
"accept_qrpay": 1,
"accept_bank": 1,
"accept_cc": 1,
"email": "1@bk.vn",
"name": "Dang Le Duc",
"webhooks": null,
"customer_name": "NGUYEN VAN A",
"customer_email": "nguyenvana@gmail.com",
"customer_phone": "0399999999",
"customer_address": null,
"created_at": "2020-05-14 13:49:09",
"updated_at": "2020-05-14 13:49:29"
}
}
}
HTTP Request
POST api/v4/linked-wallet/confirm-payment-by-wallet
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
otp | number | optional | required_without:otp Mật khẩu giao dịch |
ticket | string | required | Mã ticket |
Thanh toán từ thẻ liên kết
[API thanh toán từ thẻ liên kết]
Headers: Wallet-Token : $token
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/linked-wallet/request-payment-by-atm" -d "mrc_order_id"="0KFvVRQNdicM1Z0D" \
-d "amount"="19" \
-d "card_id"="17" \
-d "description"="3joiC5fWcmI6IaBh" \
-d "fee_amount"="15" \
-d "bank_fee_amount"="3"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/request-payment-by-atm",
"method": "POST",
"data": {
"mrc_order_id": "0KFvVRQNdicM1Z0D",
"amount": 19,
"card_id": 17,
"description": "3joiC5fWcmI6IaBh",
"fee_amount": 15,
"bank_fee_amount": 3
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['mrc_order_id'] = "0KFvVRQNdicM1Z0D";
$payload['amount'] = "19";
$payload['card_id'] = "17";
$payload['description'] = "3joiC5fWcmI6IaBh";
$payload['fee_amount'] = "15";
$payload['bank_fee_amount'] = "3";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/linked-wallet/request-payment-by-atm", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": {
"apiOperation": "PURCHASE_OTP",
"merchantId": "BAOKIMCE",
"order": {
"amount": "100550",
"creationTime": "2020-04-14T16:04:19.589Z",
"currency": "VND",
"id": "ORD_BK_1586855062"
},
"response": {
"acquirerCode": "11",
"gatewayCode": "PENDING_FOR_OTP"
},
"result": "SUCCESS",
"sourceOfFunds": {
"provided": {
"card": {
"brand": "SML",
"nameOnCard": "NGUYEN VAN A",
"issueDate": "0307",
"number": "970400xxxxxx0018",
"scheme": "OTHERS"
}
},
"type": "CARD"
},
"transaction": {
"acquirer": {
"id": "835640836",
"transactionId": "835640836"
},
"amount": "100550",
"currency": "VND",
"id": "1205628",
"type": "PAYMENT"
},
"version": "1",
"channel": "1234",
"dataKey": "cT0IN6xSIuqwRg5M8ZuyUVN\/G7fOpEz3TjPqZMvJn5Ydi+zqGS2T6B1XwpVKrh3+SzxyGchCv5lcjkQKfSJs2788Ogjmro4SrpI46q+TIUxXdoSHnVCt7\/Bc3yiuKxoIM8wuGVOiOHC\/ubQzF1z7kqZwLE0yfhVy3No64aRSJ4ps509SwfK4AFpLve+XZHUMh1P6dwjz6\/sWhL0jainf+pqZu2ByS9WagIVL8HjnZKRif0R6iyi2kpZvmFoP9AekFdSfILFQ58tGeSYgHjcKUIc+5OJtrxT7FceE4Dgqr7IqJXQzcjZjtBGyST595dGcVqeuJfDy6tSMqhptIRDMPyLlAlzVi8dEJb0+X4jVEs3kRTIagGf1R0yA01YDJf41Jao83k0YJxVTgxBuSvlLhAV9LEx7d1GzwhDSOkDRDg\/pyErtBXNznx5Vr6IfOKYv+JPz030U3WZIU5SGKXbsfQ==",
"napasKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArbP6iFl0Z9pDHv5ni\/fhl4ME6AfP16E5zmrHYftaBlcvq1bWRwk1TH23OrYQ6n6jEGIbmrVXzIM00lk723\/ZHtvbyZld8r5TcEh5M+h\/jIu3\/J9gqNYGTo9jLJ0DvRdSfzbDWJqPImPfcGJDRPTrEtckqmd8HvkU6J3MCPrg0IOGTYplUmw6DZ25g1SpBSb1CAWGqP36nqyxNZ4hNJ08agHQbRc\/ICHUb\/8+\/UjDETX96SYVn+GBKbrMM\/NcgiJV7UXbEmQ9OEiM3BbI5srhCOt0oYoCp0sJcpLcLbRlpdC7\/nV44KPty1rkZ32KlBufz3UVggXpHPz0k0yxYTvl\/wIDAQAB:MIICtTCCAZ0CBgFoko89+DANBgkqhkiG9w0BAQUFADAeMRwwGgYDVQQDExNUZXN0IENBIENlcnRpZmljYXRlMB4XDTE5MDEyODAzNDQ0N1oXDTE5MDEyOTAzNDQ0N1owHjEcMBoGA1UEAxMTVGVzdCBDQSBDZXJ0aWZpY2F0ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK2z+ohZdGfaQx7+Z4v34ZeDBOgHz9ehOc5qx2H7WgZXL6tW1kcJNUx9tzq2EOp+oxBiG5q1V8yDNNJZO9t\/2R7b28mZXfK+U3BIeTPof4yLt\/yfYKjWBk6PYyydA70XUn82w1iajyJj33BiQ0T06xLXJKpnfB75FOidzAj64NCDhk2KZVJsOg2duYNUqQUm9QgFhqj9+p6ssTWeITSdPGoB0G0XPyAh1G\/\/Pv1IwxE1\/ekmFZ\/hgSm6zDPzXIIiVe1F2xJkPThIjNwWyObK4QjrdKGKAqdLCXKS3C20ZaXQu\/51eOCj7cta5Gd9ipQbn891FYIF6Rz89JNMsWE75f8CAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAFXK48p71S87EmrnCm5Yvv42Oxzh0B18\/q4jn891xS1abFRkW2jdCvpc3IUQL6gy+JFQcY2NSaLhIYgBafmcngiBFt4kkTqUuwSdIWudl3jYkO58SOYKdxW8jbXM5KwTujpb0gYBpf1u5828RmEq6YEog\/yx\/hYQOFQlfIBBZFNmUJ7U5TDCFL2wT5MqPg2cfb1DirveD3sLSIUc90IJM3eUXfzXqkwdrCKDZRSuV3TMHChi1IRio2fg7zesi9HliFueaekkvynnwXoG41LKaMSBMM\/Mdrb2tm29jVYnlYJ8Coj+dOjWhU2y83dFi5DGr8a3ftWOc+rEz2zlOUKRF7Q==",
"user_id": 1000005,
"client_ip": "118.70.233.72",
"deposit_id": 125643,
"order_id": 6123
}
}
HTTP Request
POST api/v4/linked-wallet/request-payment-by-atm
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
mrc_order_id | string | required | Mã đơn hàng |
amount | integer | required | Số tiền thanh toán |
card_id | integer | required | ID thẻ đã lưu |
description | string | required | Mô tả đơn hàng |
fee_amount | integer | optional | phí bảo kim |
bank_fee_amount | integer | optional | phí ngân hàng |
Gửi yêu cầu huỷ liên kết thẻ ATM
Headers: Wallet-Token: $wallet_token
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/linked-wallet/request-delete-card" -d "card_id"="6.43130723"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/request-delete-card",
"method": "POST",
"data": {
"card_id": 6.43130723
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['card_id'] = "6.43130723";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/linked-wallet/request-delete-card", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"msg": [],
"count": 0,
"data": {
"ticket": "eyNmVESFNPcHdKK3JMdEQ5WDZxUmZQb3BNcjJ6N04rZWlXeVNwekViTzF4UWJTNk02VldzRzdBK3BKeU9ZdkFsekh0YXF5d0lCZlZDb3NYaUpoZmJsb3c9PQ=="
}
}
HTTP Request
POST api/v4/linked-wallet/request-delete-card
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
card_id | number | required | ID thẻ |
Xác nhận yêu cầu huỷ liên kết thẻ ATM
Headers: Wallet-Token: $wallet_token
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/linked-wallet/confirm-delete-card" -d "otp"="8XSxOrJSx6qMtYTj" \
-d "ticket"="ZugcP67k5p6aK8ny"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/confirm-delete-card",
"method": "POST",
"data": {
"otp": "8XSxOrJSx6qMtYTj",
"ticket": "ZugcP67k5p6aK8ny"
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['otp'] = "8XSxOrJSx6qMtYTj";
$payload['ticket'] = "ZugcP67k5p6aK8ny";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/linked-wallet/confirm-delete-card", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"msg": [],
"count": 0,
"data": []
}
HTTP Request
POST api/v4/linked-wallet/confirm-delete-card
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
otp | string | required | mã OTP |
ticket | string | required | Mã ticket |
Xác thực ví doanh nghiệp bằng tài khoản ngân hàng
Headers: Wallet-Token: $wallet_token
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/linked-wallet/identify-wallet-enterprise" -d "holder"="GWs681qZ1VlYiZy7" \
-d "bank_id"="1" \
-d "bank_account"="QPJwkNxXB8bSbkzY"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/linked-wallet/identify-wallet-enterprise",
"method": "POST",
"data": {
"holder": "GWs681qZ1VlYiZy7",
"bank_id": 1,
"bank_account": "QPJwkNxXB8bSbkzY"
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['holder'] = "GWs681qZ1VlYiZy7";
$payload['bank_id'] = "1";
$payload['bank_account'] = "QPJwkNxXB8bSbkzY";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/linked-wallet/identify-wallet-enterprise", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"msg": [],
"count": 0,
"data": {
"user_id": 1000005,
"bank_id": "105",
"withdraw_bpm_id": 240,
"holder": "DANG VAN DUC",
"branch": null,
"province_id": null,
"description": null,
"verify_stat": "v",
"is_active": 0,
"updated_at": "2018-12-18 05:31:15",
"created_at": "2018-12-18 05:31:15"
}
}
HTTP Request
POST api/v4/linked-wallet/identify-wallet-enterprise
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
holder | string | required | Tên người in trên thẻ |
bank_id | integer | required | bank_id từ https://developer.baokim.vn/payment/#bank-api |
bank_account | string | required | Số tài khoản atm |
Order API
Order API cung cấp các API phục vụ việc tích hợp thanh toán đơn hàng/sản phẩm từ các website/app bán hàng/nội dung số...
Bạn cần hiểu rõ các quy trình tích hợp thanh toán Bảo Kim cung cấp trước khi thực hiện tích hợp thanh toán
Send Order
[API Gửi thông tin đơn hàng từ ứng dụng của user sang Bảo Kim để thực hiện thanh toán.]
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/order/send" -d "mrc_order_id"="HVfwM6CJqahyofJ2" \
-d "total_amount"="4" \
-d "description"="dPqWyNY6YLHNA1bN" \
-d "url_success"="QN62B3Sx0ElEs058" \
-d "merchant_id"="3" \
-d "url_detail"="1zPnqsBlpuUHGYyY" \
-d "lang"="4zuYn1RPQzNUlIAZ" \
-d "bpm_id"="11" \
-d "accept_bank"="BxRJqH08zNcTdmKf" \
-d "accept_cc"="d5qMVMmsRw7QDidv" \
-d "accept_qrpay"="CiP6QMMtVhwWpj8i" \
-d "accept_e_wallet"="FI3P0W5t97sBT2Zh" \
-d "webhooks"="dPHzfYHryoM3MOMb" \
-d "customer_email"="6zS9bR9yUEew3al2" \
-d "customer_phone"="B300jstOWogy2j0h" \
-d "customer_name"="M0AvQ9fbTeiVKSUr" \
-d "customer_address"="8FsIgSW5wyPoAnB1"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/order/send",
"method": "POST",
"data": {
"mrc_order_id": "HVfwM6CJqahyofJ2",
"total_amount": 4,
"description": "dPqWyNY6YLHNA1bN",
"url_success": "QN62B3Sx0ElEs058",
"merchant_id": 3,
"url_detail": "1zPnqsBlpuUHGYyY",
"lang": "4zuYn1RPQzNUlIAZ",
"bpm_id": 11,
"accept_bank": "BxRJqH08zNcTdmKf",
"accept_cc": "d5qMVMmsRw7QDidv",
"accept_qrpay": "CiP6QMMtVhwWpj8i",
"accept_e_wallet": "FI3P0W5t97sBT2Zh",
"webhooks": "dPHzfYHryoM3MOMb",
"customer_email": "6zS9bR9yUEew3al2",
"customer_phone": "B300jstOWogy2j0h",
"customer_name": "M0AvQ9fbTeiVKSUr",
"customer_address": "8FsIgSW5wyPoAnB1"
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['mrc_order_id'] = "HVfwM6CJqahyofJ2";
$payload['total_amount'] = "4";
$payload['description'] = "dPqWyNY6YLHNA1bN";
$payload['url_success'] = "QN62B3Sx0ElEs058";
$payload['merchant_id'] = "3";
$payload['url_detail'] = "1zPnqsBlpuUHGYyY";
$payload['lang'] = "4zuYn1RPQzNUlIAZ";
$payload['bpm_id'] = "11";
$payload['accept_bank'] = "BxRJqH08zNcTdmKf";
$payload['accept_cc'] = "d5qMVMmsRw7QDidv";
$payload['accept_qrpay'] = "CiP6QMMtVhwWpj8i";
$payload['accept_e_wallet'] = "FI3P0W5t97sBT2Zh";
$payload['webhooks'] = "dPHzfYHryoM3MOMb";
$payload['customer_email'] = "6zS9bR9yUEew3al2";
$payload['customer_phone'] = "B300jstOWogy2j0h";
$payload['customer_name'] = "M0AvQ9fbTeiVKSUr";
$payload['customer_address'] = "8FsIgSW5wyPoAnB1";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/order/send", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": {
"order_id": 50911,
"redirect_url": "\/payment\/?oid=50911&checksum=50f1c60363c29c19b1c18359f1b4cfc655165117",
"payment_url": "http:\/\/sandbox.baokim.vn\/payment\/?oid=50911&checksum=50f1c60363c29c19b1c18359f1b4cfc655165117",
"bank_account": {
"acc_name": "Tên tài khoản ngân hàng",
"acc_no": "Số tài khoản ngân hàng",
"bank_name": "Tên ngân hàng",
"branch": "Chi nhánh",
"amount": "Số tiền cần chuyển khoản"
}
}
}
HTTP Request
POST api/v4/order/send
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
mrc_order_id | string | required | mã đơn hàng của merchant |
total_amount | integer | required | tổng số tiền đơn hàng |
description | string | required | Mô tả giao dịch |
url_success | string | required | Url redirect lại sau khi thanh toán thành công |
merchant_id | integer | optional | mã id của website Từ xác thực website |
url_detail | string | optional | Url chi tiết đơn hàng (redirect lại khi khách hủy đơn) |
lang | string | optional | Ngôn ngữ (en/vi) |
bpm_id | integer | optional | ID phương thức thanh toán từ ngân hàng Từ API Bank Payment Method List |
accept_bank | int(0,1) | optional | Chấp nhận thanh toán bằng thẻ ATM ? (Chấp nhận: 1, Không chấp nhận: 0, default: 1) |
accept_cc | int(0,1) | optional | Chấp nhận thanh toán bằng thẻ Tín dụng ? (Chấp nhận: 1, Không chấp nhận: 0, default: 1) |
accept_qrpay | int(0,1) | optional | Chấp nhận thanh toán bằng QR code ? (Chấp nhận: 1, Không chấp nhận: 0, default: 0) |
accept_e_wallet | int(0,1) | optional | Chấp nhận thanh toán bằng Ví điện tử ? (Chấp nhận: 1, Không chấp nhận: 0, default: 1) |
webhooks | string | optional | url dùng để gửi thông báo cho website bán hàng, chat, ... khi đơn hàng thanh toán thành công, cho phép notify đến nhiều url, cách nhau bởi dấu , |
customer_email | string | optional | Email khách hàng |
customer_phone | string | optional | Số điện thoại khách hàng |
customer_name | string | optional | Họ và tên khách hàng |
customer_address | string | optional | Địa chỉ khách hàng |
Order Detail
[API Get chi tiết thông tin đơn hàng, có thể dùng để kiểm tra trạng thái thanh toán đơn hàng.] Đơn hàng được coi là đã thanh toán thành công khi có:
- stat == 'c' //completed
- txn_id (mã giao dịch thanh toán) có giá trị
- bạn cũng có thể sử dụng API Transaction Detail để kiểm tra thông tin giao dịch nếu cần thiết.
Chú ý: Với giao dịch thanh toán từ thẻ tín dụng, đơn hàng có thể ở trạng thái chờ 'r' (Reviewing). Trường hợp này khách hàng đã thanh toán nhưng giao dịch phải chờ phía Ngân hàng duyệt. Bảo Kim sẽ không cộng số dư ví cho Merchant cho đến khi ngân hàng duyệt. Việc giao hàng ngay hay đợi duyệt sẽ cho phía Merchant tự quyết định.
Danh sách trạng thái đơn hàng:
- 'p': processing (đang xử lý)
- 'c': completed (hoàn thành, đã thanh toán thành công)
- 'r': reviewing (khách đã thanh toán, nhưng tiền chờ duyệt, áp dụng đối với 1 số thẻ visa, rất ít)
- 'd': destructed (hủy thanh toán, hủy duyệt tiền thanh toán visa)
Example request:
curl -X GET -G "https://api.baokim.vn/payment/api/v4/order/detail"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/order/detail",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$options['query']['id'] = 'LXqbhMZWMx7iOec5';
$options['query']['mrc_order_id'] = 'IdUxK3IKURCCbQCp';
$response = $client->request("GET", "https://api.baokim.vn/payment/api/v4/order/detail", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": {
"id": 45458,
"user_id": "1000005",
"mrc_order_id": "mrc_1543306400",
"txn_id": null,
"ref_no": null,
"deposit_id": null,
"merchant_id": null,
"total_amount": "100000.00",
"shipping_fee": "0.00",
"tax_fee": "0.00",
"mrc_fee": null,
"description": "thanh toan don hang 1543306400",
"url_success": "https:\/\/vnexpress.net\/",
"url_cancel": null,
"url_detail": null,
"stat": "p",
"payment_version": "4.0",
"lang": "vi",
"bpm_id": 0,
"accept_qrpay": 0,
"created_at": "2018-11-27 08:13:22",
"updated_at": "2018-11-27 08:13:22"
}
}
HTTP Request
GET api/v4/order/detail
Query Parameters
Parameter | Status | Description |
---|---|---|
id | optional | ID đơn hàng [semi-optional] |
mrc_order_id | optional | Mã đơn hàng duy nhất được tạo bảo merchant [semi-optional] |
List Order
[API Get danh sách đơn hàng của user, có thể sử dụng để đối soát đơn hàng giữa ứng dụng và Bảo Kim.]
Example request:
curl -X GET -G "https://api.baokim.vn/payment/api/v4/order/list"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/order/list",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$options['query']['mrc_order_id'] = 'h96oVbfVSo41RCbZ';
$options['query']['txn_id'] = 'ab0JVxfbgV7dQ0wa';
$options['query']['stat'] = 'xg4YqsZDTukH4GO1';
$options['query']['from_date'] = 'bNYxbCoZKJxSnROm';
$options['query']['to_date'] = 'vQBxCra6OKnpBKdC';
$options['query']['per_page'] = 't8fXJZyrjUbOE7F6';
$options['query']['page'] = '7';
$response = $client->request("GET", "https://api.baokim.vn/payment/api/v4/order/list", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": {
"current_page": 2,
"data": [
{
"id": 3,
"user_id": "100000",
"mrc_order_id": "71364",
"txn_id": null,
"ref_no": "1000033",
"deposit_id": null,
"merchant_id": 6,
"total_amount": "4000.00",
"shipping_fee": "0.00",
"tax_fee": "0.00",
"mrc_fee": null,
"description": "Mua hàng tại Vatgia.com, mã đơn hàng dienthoaigiatot_20100420153128",
"url_success": "http:\/\/vatgia.com\/baokim\/return_payment.php",
"url_cancel": "",
"url_detail": "http:\/\/vatgia.com\/profile\/?module=order_detail&record_id=71364",
"stat": null,
"payment_version": null,
"lang": "vi",
"bpm_id": 0,
"accept_qrpay": 0,
"created_at": "-0001-11-30 00:00:00",
"updated_at": "-0001-11-30 00:00:00"
}
]
}
}
HTTP Request
GET api/v4/order/list
Query Parameters
Parameter | Status | Description |
---|---|---|
mrc_order_id | optional | mã đơn hàng |
txn_id | optional | mã giao dịch |
stat | optional | trạng thái đơn hàng |
from_date | optional | đơn hàng từ ngày |
to_date | optional | đơn hàng đến ngày |
per_page | optional | tổng số dòng trên một trang |
page | optional | page index cần lấy |
Cancel Order
[API hủy đơn hàng, sử dụng trong trường hợp không muốn nhận thanh toán cho đơn hàng nữa]
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/order/cancel" -d "id"="8"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/order/cancel",
"method": "POST",
"data": {
"id": 8
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['id'] = "8";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/order/cancel", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": {
"id": 45458,
"user_id": "1000005",
"mrc_order_id": "mrc_1543306400",
"txn_id": null,
"ref_no": null,
"deposit_id": null,
"merchant_id": null,
"total_amount": "100000.00",
"shipping_fee": "0.00",
"tax_fee": "0.00",
"mrc_fee": null,
"description": "thanh toan don hang 1543306400",
"url_success": "https:\/\/vnexpress.net\/",
"url_cancel": null,
"url_detail": null,
"stat": "d",
"payment_version": "4.0",
"lang": "vi",
"bpm_id": 0,
"accept_qrpay": 0,
"created_at": "2018-11-27 08:13:22",
"updated_at": "2018-11-27 08:13:22"
}
}
HTTP Request
POST api/v4/order/cancel
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
id | integer | required | mã đơn hàng |
Refund API
Api cho quản trị hoàn tiền các giao dịch đã hoàn thành
Create Refund
[Tạo giao dịch hoàn tiền]
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/refund/create" -d "txn_id"="RqOKoYbvSkfy5L3q" \
-d "description"="NyFXjB0uZlr30viK" \
-d "chanel"="Oul3c4nRbEgBHVOQ"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/refund/create",
"method": "POST",
"data": {
"txn_id": "RqOKoYbvSkfy5L3q",
"description": "NyFXjB0uZlr30viK",
"chanel": "Oul3c4nRbEgBHVOQ"
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['txn_id'] = "RqOKoYbvSkfy5L3q";
$payload['description'] = "NyFXjB0uZlr30viK";
$payload['chanel'] = "Oul3c4nRbEgBHVOQ";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/refund/create", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 2,
"data": [
{
"user_id": 1000005,
"account_id": 1001000079,
"amount": -99000,
"fee_amount": -1000,
"description": "Hoàn tiền giao dịch :32365",
"ref_no": "REF_32365",
"stat": 4,
"type": 7,
"src_des": "hoàn tiền đến giao dịch 32365",
"updated_at": "2019-03-15 04:35:48",
"created_at": "2019-03-15 04:35:48",
"id": 32375
},
{
"user_id": 1015669,
"account_id": 1001005056,
"amount": 100000,
"fee_amount": 0,
"description": "Hoàn tiền giao dịch :32365",
"ref_no": "REF_32365",
"stat": 4,
"type": 7,
"src_des": "hoàn tiền đến giao dịch 32365",
"updated_at": "2019-03-15 04:35:48",
"created_at": "2019-03-15 04:35:48",
"id": 32376
}
]
}
HTTP Request
POST api/v4/refund/create
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
txn_id | numeric | required | mã giao dịch |
description | string | required | nội dung hoàn (max : 255 ký tự) |
chanel | string | optional | kênh hoàn tiền chọn hoàn về bank hay Bảo kim (BANK, BAOKIM) |
Transaction API
Các API về giao dịch
Transaction list
[API truy xuất thông tin lịch sử giao dịch của user, có thể sử dụng trong đối soát giao dịch]
Example request:
curl -X GET -G "https://api.baokim.vn/payment/api/v4/txn/list"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/txn/list",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$options['query']['txn_id'] = 'XOWUrZSBBGjKgDyD';
$options['query']['type'] = 'SAwPLqhCyKuo2fqi';
$options['query']['ref_no'] = 'qC6bCfo6SpvINgHN';
$options['query']['stat'] = 'ajFAMsbdj2guYvej';
$options['query']['from_date'] = 'wl2krnIipHxnmuex';
$options['query']['to_date'] = 'gyTYBJoSSYtjG8zZ';
$options['query']['page'] = '12';
$options['query']['per_page'] = 'njQr0ncx2YA0fkbp';
$response = $client->request("GET", "https://api.baokim.vn/payment/api/v4/txn/list", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 1537,
"data": {
"current_page": 4,
"data": [
{
"id": 10313,
"user_id": 1000005,
"account_id": 1001000079,
"opening_balance": "5308590.00",
"amount": "-10300.00",
"balance": "5298290.00",
"opening_freeze_balance": "525306122.96",
"freeze_amount": "0.00",
"freeze_balance": "525306122.96",
"ref_no": "1026288",
"bank_ref_no": null,
"type": null,
"stat": 4,
"description": null,
"fee_amount": "0.00",
"is_processed": 1,
"src_des": null,
"created_at": "2016-02-26 10:09:58",
"updated_at": "-0001-11-30 00:00:00"
}
]
}
}
HTTP Request
GET api/v4/txn/list
Query Parameters
Parameter | Status | Description |
---|---|---|
txn_id | optional | mã giao dịch |
type | optional | loại giao dịch 1:nạp, 3:rút, 5:chuyển, 7:hoàn |
ref_no | optional | Mã tham chiếu |
stat | optional | trạng thái giao dịch |
from_date | optional | giao dịch từ ngày |
to_date | optional | giao dịch đến ngày |
page | optional | page index cần lấy |
per_page | optional | Số bản ghi trên 1 trang |
Transaction detail
[API truy xuất thông tin chi tiết 1 giao dịch]
Example request:
curl -X GET -G "https://api.baokim.vn/payment/api/v4/txn/detail"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/txn/detail",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$options['query']['txn_id'] = 'DougUvu2ObH37WGc';
$response = $client->request("GET", "https://api.baokim.vn/payment/api/v4/txn/detail", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": {
"id": 27585,
"user_id": 1000005,
"account_id": 1001000079,
"opening_balance": "1111968443.45",
"amount": "10000.00",
"balance": "1111978443.45",
"opening_freeze_balance": "562387181.18",
"freeze_amount": "0.00",
"freeze_balance": "562387181.18",
"ref_no": "1040791",
"bank_ref_no": "vcb_1543390288",
"type": null,
"stat": 4,
"description": "ut nap tien 1@bk.vn",
"fee_amount": "0.00",
"is_processed": 1,
"src_des": null,
"created_at": "2018-11-28 07:31:28",
"updated_at": "2018-11-28 07:31:28"
}
}
HTTP Request
GET api/v4/txn/detail
Query Parameters
Parameter | Status | Description |
---|---|---|
txn_id | required | mã giao dịch |
Transfer API
API thực hiện giao dịch chuyển tiền cho user khác
Create transfer
[API Chuyển tiền từ ví Bảo Kim sang cho user khác]
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/transfer/create" -d "to_user"="pQhWLPtZ9q5IXQda" \
-d "amount"="iUCJXIV9pRONRmE1" \
-d "description"="dkziUsnQqwW4bNnJ" \
-d "verification_code"="QM4OKSXo0iztrq7s" \
-d "fee_payer"="J1PZyfHtzRdggn8U" \
-d "txn_mode"="C5BMTby7PBFXJZmx" \
-d "order_id"="16"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/transfer/create",
"method": "POST",
"data": {
"to_user": "pQhWLPtZ9q5IXQda",
"amount": "iUCJXIV9pRONRmE1",
"description": "dkziUsnQqwW4bNnJ",
"verification_code": "QM4OKSXo0iztrq7s",
"fee_payer": "J1PZyfHtzRdggn8U",
"txn_mode": "C5BMTby7PBFXJZmx",
"order_id": 16
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['to_user'] = "pQhWLPtZ9q5IXQda";
$payload['amount'] = "iUCJXIV9pRONRmE1";
$payload['description'] = "dkziUsnQqwW4bNnJ";
$payload['verification_code'] = "QM4OKSXo0iztrq7s";
$payload['fee_payer'] = "J1PZyfHtzRdggn8U";
$payload['txn_mode'] = "C5BMTby7PBFXJZmx";
$payload['order_id'] = "16";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/transfer/create", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": {
"transfer": {
"from_account_id": 1001000079,
"to_account_id": 1001005056,
"amount": "20000",
"description": "no",
"fee_from": 0,
"fee_to": 0,
"stat": 1,
"updated_at": "2018-12-14 04:00:36",
"created_at": "2018-12-14 04:00:36",
"id": 73
},
"txn": {
"user_id": 1000005,
"account_id": 1001000079,
"amount": -20000,
"fee_amount": 0,
"fee_display": 0,
"description": "no",
"ref_no": 73,
"stat": 4,
"updated_at": "2018-12-14 04:00:36",
"created_at": "2018-12-14 04:00:36",
"id": 27716
}
}
}
HTTP Request
POST api/v4/transfer/create
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
to_user | string | required | email/phone user thụ hưởng |
amount | decimal | required | Số tiền chuyển |
description | string | required | Nội dung giao dịch |
verification_code | string | optional | Mã xác thực 2FA (không áp dụng cho user sử dụng API Key) |
fee_payer | int[1,2] | optional | optional User trả phí, 1: user chuyển, 2: user nhận, default: 2 |
txn_mode | int[1,2] | optional | optional chế độ giao dịch, 1: trực tiếp, 2: an toàn, default: 1 |
order_id | integer | optional | optional Mã đơn hàng nếu là chuyển tiền thanh toán cho đơn hàng |
VAT API
Các API về dịch vụ gia tăng của Bảo Kim (topup/mã thẻ/thẻ game/...)
List
[API trả về danh sách các dịch vụ giá trị gia tăng Bảo kim hỗ trợ. Merchant sử dụng tham số id
trong items
trả về trong API này để dùng trong API mua dịch vụ]
Example request:
curl -X GET -G "https://api.baokim.vn/payment/api/v4/vat/list"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/vat/list",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$response = $client->request("GET", "https://api.baokim.vn/payment/api/v4/vat/list", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 3,
"data": [
{
"info": {
"id": 1,
"code": "CARD_MOBILE",
"description": "Thẻ điện thoại",
"account_recieve": 1015669,
"stat": 1,
"created_at": "2019-02-26 03:17:04",
"updated_at": "-0001-11-30 00:00:00"
},
"items": [
{
"id": 1,
"service_id": 1,
"param": "VIETTEL",
"name": "VIETTEL",
"discount": "0.00",
"partner": "ecopay",
"list_amount": "10,20,50,100,200,500",
"stat": 1,
"created_at": "2019-02-26 03:11:31",
"updated_at": "-0001-11-30 00:00:00"
},
{
"id": 2,
"service_id": 1,
"param": "VINAPHONE",
"name": "VINAPHONE",
"discount": "0.00",
"partner": "ecopay",
"list_amount": "10,20,50,100,200,500",
"stat": 1,
"created_at": "2019-02-26 03:10:46",
"updated_at": "-0001-11-30 00:00:00"
}
]
},
{
"info": {
"id": 2,
"code": "TOPUP_MOBILE",
"description": "Nạp tiền điện thoại",
"account_recieve": 1015669,
"stat": 1,
"created_at": "2019-02-26 03:17:06",
"updated_at": "-0001-11-30 00:00:00"
},
"items": [
{
"id": 5,
"service_id": 2,
"param": "VIETTEL",
"name": "VIETTEL",
"discount": "0.00",
"partner": "ecopay",
"list_amount": "10,20,50,100,200,500",
"stat": 1,
"created_at": "2019-02-26 03:10:48",
"updated_at": "-0001-11-30 00:00:00"
},
{
"id": 6,
"service_id": 2,
"param": "VINAPHONE",
"name": "VINAPHONE",
"discount": "0.00",
"partner": "ecopay",
"list_amount": "10,20,50,100,200,500",
"stat": 1,
"created_at": "2019-02-26 03:10:49",
"updated_at": "-0001-11-30 00:00:00"
}
]
}
]
}
HTTP Request
GET api/v4/vat/list
Purchase
[API cho merchant mua dịch vụ giá trị gia tăng của Bảo kim]
- Khách hàng dùng tham số
success
để kiểm tra dịch vụ thành công hay chưa : (1, Thành công), (0, Chưa thành công, liên hệ hỗ trợ)
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/vat/purchase" -d "mrc_order_id"="o54PObidwM4KmG8W" \
-d "service_item_id"="15" \
-d "amount"="9" \
-d "phone"="bzfmIOLxfUayWnkR"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/vat/purchase",
"method": "POST",
"data": {
"mrc_order_id": "o54PObidwM4KmG8W",
"service_item_id": 15,
"amount": 9,
"phone": "bzfmIOLxfUayWnkR"
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['mrc_order_id'] = "o54PObidwM4KmG8W";
$payload['service_item_id'] = "15";
$payload['amount'] = "9";
$payload['phone'] = "bzfmIOLxfUayWnkR";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/vat/purchase", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": {
"success": 0,
"mrc_order_id": "101566938",
"service_item_id": "2",
"service": "CARD_MOBILE",
"param": "VINAPHONE",
"amount": 10000,
"pin": "",
"seri": "",
"transaction_id": "36719",
"created_at": "2019-05-13 01:01:41"
}
}
HTTP Request
POST api/v4/vat/purchase
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
mrc_order_id | string | required | Mã đơn hàng (Tạo trên hệ thống của Merchant, là duy nhất) |
service_item_id | integer | optional | Mã dịch vụ (lấy trong API Service list ) |
amount | integer | required | Mệnh giá thẻ cào/giá trị nạp (lấy trong API Service list ) |
phone | string | optional | Số điện thoại nhập Topup (required nếu mua Topup) |
Virtual Account
Create virtual account
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/create-virtual-account-payment" -d "mrc_uui"="RSqk0eaXjOhxrwAU" \
-d "name"="GX6iN7ctOop6E31l" \
-d "mrc_id"="XXuoIq5VOAHmUbmf"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/create-virtual-account-payment",
"method": "POST",
"data": {
"mrc_uui": "RSqk0eaXjOhxrwAU",
"name": "GX6iN7ctOop6E31l",
"mrc_id": "XXuoIq5VOAHmUbmf"
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['mrc_uui'] = "RSqk0eaXjOhxrwAU";
$payload['name'] = "GX6iN7ctOop6E31l";
$payload['mrc_id'] = "XXuoIq5VOAHmUbmf";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/create-virtual-account-payment", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
HTTP Request
POST api/v4/create-virtual-account-payment
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
mrc_uui | text | required | User ID |
name | text | required | Name of merchant or Name company |
mrc_id | text | required | ID Website integration |
Update virtual account
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/update-virtual-account-payment" -d "acc_no"="azG1nJYnB1mqcsTV" \
-d "name"="H2TKRf2eAlfIsW9x"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/update-virtual-account-payment",
"method": "POST",
"data": {
"acc_no": "azG1nJYnB1mqcsTV",
"name": "H2TKRf2eAlfIsW9x"
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['acc_no'] = "azG1nJYnB1mqcsTV";
$payload['name'] = "H2TKRf2eAlfIsW9x";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/update-virtual-account-payment", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
HTTP Request
POST api/v4/update-virtual-account-payment
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
acc_no | text | required | Virtual Account |
name | text | required | Name of merchant or Name company |
Withdraw API
API thực hiện giao dịch rút tiền từ ví => ngân hàng
Create Withdrawal
[API thực hiện rút tiền từ ví Bảo Kim về Thẻ/Tài khoản Ngân hàng]
Example request:
curl -X POST "https://api.baokim.vn/payment/api/v4/withdraw/create" -d "card_id"="6" \
-d "bank_account_id"="12" \
-d "amount"="DYbaomKai2sPE7mq" \
-d "descripton"="CYXMJcuGPyJ466AF" \
-d "verification_code"="aitfY5g0JsuAZZUP"
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.baokim.vn/payment/api/v4/withdraw/create",
"method": "POST",
"data": {
"card_id": 6,
"bank_account_id": 12,
"amount": "DYbaomKai2sPE7mq",
"descripton": "CYXMJcuGPyJ466AF",
"verification_code": "aitfY5g0JsuAZZUP"
},
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//pre-requisites: install Guzzle package https://github.com/guzzle/guzzle
$client = new GuzzleHttp\Client(['timeout' => 20.0]);
$options['query']['jwt'] = BaoKimAPI::getToken();
$payload['card_id'] = "6";
$payload['bank_account_id'] = "12";
$payload['amount'] = "DYbaomKai2sPE7mq";
$payload['descripton'] = "CYXMJcuGPyJ466AF";
$payload['verification_code'] = "aitfY5g0JsuAZZUP";
$options['form_params'] = $payload;
$response = $client->request("POST", "https://api.baokim.vn/payment/api/v4/withdraw/create", $options);
echo "Response status code: " . $response->getStatusCode();
echo "Response data: ". $response->getBody()->getContent();
Example response:
{
"code": 0,
"message": [],
"count": 0,
"data": {
"withdrawal": {
"user_id": 1000005,
"account_id": 1001000079,
"card_id": 475,
"description": "rut tien ve the vcb",
"stat": 6,
"amount": "10000",
"fee_amount": 50000,
"net_amount": -40000,
"updated_at": "2018-12-18 05:31:15",
"created_at": "2018-12-18 05:31:15",
"id": 454
},
"txn": {
"user_id": 1000005,
"account_id": 1001000079,
"amount": -60000,
"fee_amount": 50000,
"fee_display": 50000,
"description": "rut tien ve the vcb",
"ref_no": 454,
"stat": 4,
"updated_at": "2018-12-18 05:31:15",
"created_at": "2018-12-18 05:31:15",
"id": 27815
}
}
}
HTTP Request
POST api/v4/withdraw/create
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
card_id | integer | optional | required_without:bank_account_id ID Tài khoản Nhận tiền |
bank_account_id | integer | optional | required_without:card_id ID Thẻ Nhận tiền |
amount | decimal | required | Số tiền rút |
descripton | string | required | Nội dung giao dịch |
verification_code | string | optional | Mã xác thực 2FA, không áp dụng đối với giao dịch xác thực qua user API Key |