Create Payment
Path
- URL:
/cb-core/api/v1/payment/create - Method:
POST - Description: This API is used to create an payment. Now we only support payment method is VA, another payment method will be supported soon
Request
Request Table
| Params | Data Type + Length | Required | Description |
|---|---|---|---|
| request_id | string(50) | Yes | Unique request ID, suggested format: MerchantCode+YYYYMMDDHHMMSS+UniqueId |
| request_time | string(19) | Yes | Request time in format: YYYY-MM-DD HH:MM:SS |
| merchant_code | string(20) | Yes | Merchant code provided by Baokim before integration |
| sub_merchant_code | string(20) | Yes | If the Seller is under your sub-merchant, fill your sub merchant code provided by Baokim. If Seller is under you, fill your Merchant_code provided by Baokim as above |
| seller_id | string(50) | Yes | Seller ID on merchant's system |
| merchant_payment_id | string(50) | Yes | Merchant payment's ID |
| amount | decimal(12,2) | Yes | Amount of the payment |
| currency | string(3) | Yes | The currency code of the order Fill VND for VND transaction |
| description | string(255) | Yes | Description of the payment |
| payment_method | string(20) | Yes | Payment method ATM/CREDIT/VA/QRCODE |
| card | object | Conditional | Card information required if payment method is ATM/CREDIT |
| card.type | string(20) | Conditional | Card type ATM/CREDIT |
| card.information | string(500) | Conditional | Card information Encrypted card information. If save_token is true, this field is not required. If save_token is false, this field is required. |
| extensions | object | No | Extension of the order. extensions.key1 = value1, extensions.key2 = value2 |
| payment_url | string(255) | Yes | URL of website where transaction is created |
| payment_expire | string(19) | Yes | The expired time of the order. Maximum time is 30 minutes since the payment of order is created. Format: YYYY-MM-DD HH:MM:SS |
Request Example
Request example for payment method is QRCODE/VA
{
{
"request_id": "MERCHANT12345678901234510281",
"request_time": "2024-11-15 14:36:00",
"merchant_code": "PHUONGTT",
"sub_merchant_code": "SUBPHUONGTT",
"seller_id": "SELLER12345678901234510281",
"merchant_payment_id": "1234567890",
"amount": "300000.00",
"currency": "VND",
"payment_method": "VA",
"payment_period": "2024-11-15 15:36:00",
"extensions": {
"key1": "value1",
"key2": "value2"
},
"payment_url": "https://baokim.vn",
"payment_expire": "2024-11-15 15:36:00"
}
}
Request example for payment method is ATM/CREDIT
(Note: Encrypt card information before sending request) card.information is a base64 encoded string, which is encoded using AES-256-CBC encryption. Key and iv will be sent to merchant by Baokim before the integration.
Card information example before encryption
{
"number": "4242424242424242",
"first_name": "A",
"last_name": "Nguyen Van",
"expiration_month": "12",
"expiration_year": "2025",
"security_code": "123",
"country": "Viet Nam",
"cvn": "123"
}
Card information example after encryption
{
"card": {
"information": "5f+7bD4XzMZGdfm7hXV2YmtlnMZ5PtHmsnU4v+NdeLg=",
}
}
Example request body using credit card
{
"request_id": "MERCHANT12345678901234510281",
"request_time": "2024-11-15 14:36:00",
"merchant_code": "PHUONGTT",
"sub_merchant_code": "SUBPHUONGTT",
"seller_id": "SELLER12345678901234510281",
"merchant_payment_id": "1234567890",
"amount": "300000.00",
"currency": "VND",
"payment_method": "ATM",
"card": {
"type": "ATM",
"information": "5f+7bD4XzMZGdfm7hXV2YmtlnMZ5PtHmsnU4v+NdeLg=",
}
}
Response
Response Table
| Params | Data Type + Length | Required | Description |
|---|---|---|---|
| response_code | int(4) | Yes | Error code from Baokim as per Error Codes Table |
| response_message | string(100) | Yes | Description of the error code from Baokim as per Error Codes Table |
| data | object | Yes | Data of the response |
| data.merchant_code | string(20) | Yes | Merchant code provided by Baokim before integration |
| data.sub_merchant_code | string(20) | Yes | Sub merchant code provided by Baokim before integration |
| data.seller_id | string(100) | Yes | Seller ID on merchant's system |
| data.order_code | string(20) | Yes | The order code in Baokim system. This code is unique |
| data.payment | object | Yes | Data of the payment |
| data.payment.transaction_id | string(100) | Yes | The transaction code in Baokim system. This code is unique |
| data.payment.amount | decimal(12,2) | Yes | Amount of the transaction |
| data.payment.merchant_payment_id | string(100) | Yes | The reference code of order managed in your system. This code is unique |
| data.payment.currency | string(3) | Yes | Currency of the order |
| data.payment.va_info | object | Yes | Infomation of virtual account when payment method is VA |
| data.payment.va_info.qr_code | string(255) | Conditional | QR code of the order if payment method is QRCODE/VA |
| data.payment.va_info.qr_path | string(255) | Conditional | QR code path of the order if payment method is QRCODE/VA |
| data.payment.va_info.account_name | string(255) | Conditional | Account name of the order if payment method is QRCODE/VA |
| data.payment.va_info.account_no | string(255) | Conditional | Account number of the order if payment method is QRCODE/VA |
| data.payment.va_info.bank_no | string(255) | Conditional | Bank number of the order if payment method is QRCODE/VA |
| data.payment.va_info.bank_branch | string(255) | Conditional | Bank branch of the order if payment method is QRCODE/VA |
Response Example
{
"response_code": 200,
"response_message": "Success",
"data": {
"merchant_code": "PHUONGTT",
"sub_merchant_code": "PHUONGTT",
"seller_id": "SELLER12345678901234510281",
"order_code": "ORDER12345678901234510281",
"payment": {
"transaction_id": "TRANSACTION12345678901234510281",
"amount": "300000.00",
"merchant_payment_id": "1234567890",
"currency": "VND",
"payment_method": "VA",
"va_info": {
"qr_code": "ORDER12345678901234510281",
"qr_path": "https://example.com/qr/ORDER12345678901234510281.jpg",
"account_name": "BAOKIM PHUONGTT",
"account_no": "963336009805939",
"bank_no": "970418",
"bank_branch": "Hà Nội"
}
}
}
}
Error Code
| Response Code | Response Message |
|---|---|
| 200 | Success |
| 99 | Pending |
| 11 | Failed |
| 101 | System Error |
| 110 | Merchant Code Invalid |
| 120 | Invalid Signature |
| 422 | Validation Error |