Create Order
Flow
Description:
- Merchant calls this API to create an order on Baokim and receive payment link.
- If response.code = 100: Baokim processes the transaction and returns result via Payment Webhook.
- If response.code = 101: Merchant must redirect customer browser to redirect_url, after successful payment Baokim returns result via Payment Webhook.
Note on Auto Debit payment method (payment_method = 22):
- Registration without payment: pass total_amount = 0.
- Registration with payment: pass total_amount > 0.
- Require auto debit payment: must pass payment_info.token and total_amount > 0.
- Description content used as transfer content, maximum 120 characters.
API Information
Method: POST
URL: /b2b/core/api/ext/mm/order/send
Request
Main Parameters Table
| No. | Parameter | Data Type | Required | Description |
|---|---|---|---|---|
| 1 | request_id | String(50) | ✅ | Request ID |
| 2 | request_time | Datetime | ✅ | Request time. Format: YYYY-MM-DD H:m:s |
| 3 | master_merchant_code | String(50) | ✅ | Master merchant code provided by Baokim |
| 4 | sub_merchant_code | String(50) | ✅ | Sub merchant code provided by Baokim |
| 5 | store_code | String(50) | ❌ | Store code |
| 6 | branch_code | String(50) | ❌ | Branch code |
| 7 | staff_code | String(50) | ❌ | Sales staff code |
| 8 | service_code | String(50) | ❌ | Service code (required if Auto Debit) |
| 9 | mrc_order_id | String(50) | ✅ | Merchant's order ID |
| 10 | description | String(255) | ✅ | Order description |
| 11 | total_amount | Integer | ✅ | Total order amount (= 0 if registration only) |
| 12 | url_success | String | ✅ | Redirect URL when payment succeeds |
| 13 | url_fail | String | ✅ | Redirect URL when payment fails |
| 14 | save_token | Integer | ❌ | Save card information: 0 = No (default), 1 = Yes |
| 15 | items | Array of objects | ❌ | Product list (see table below) |
| 16 | customer_info | Object | ❌ | Customer information (see table below) |
| 17 | payment_info | Object | ❌ | Payment information (see table below) |
| 18 | payment_method | Integer | ❌ | Payment method — required for Pro integration (see table below) |
Payment Method Information (payment_method)
| Value | Method |
|---|---|
| 1 | VA |
| 2 | BNPL |
| 3 | Credit Card |
| 4 | Card Installment |
| 5 | ATM |
| 6 | VNPayQR |
| 22 | Auto debit |
Payment Information (payment_info)
| No. | Parameter | Data Type | Required | Description |
|---|---|---|---|---|
| 1 | token | String | ❌ | Payment token (required if card_hash null) |
| 2 | card_hash | String | ❌ | Encrypted card information (required if token null) |
Product Information (items)
| No. | Parameter | Data Type | Required | Description |
|---|---|---|---|---|
| 1 | code | String | ❌ | Product code |
| 2 | name | String | ❌ | Product name |
| 3 | amount | Integer | ❌ | Product price |
| 4 | quantity | Integer | ❌ | Quantity |
| 5 | link | String | ❌ | Product link |
Customer Information (customer_info)
| No. | Parameter | Data Type | Required | Description |
|---|---|---|---|---|
| 1 | code | String | ❌ | Customer code |
| 2 | name | String | ❌ | Customer name |
| 3 | String | ❌ | ||
| 4 | phone | String | ❌ | Phone number |
| 5 | address | String | ❌ | Address |
| 6 | gender | Integer | ❌ | Gender: 1 = Male, 2 = Female |
Request Example
{
"request_id": "RQID0001",
"request_time": "2023-08-18 10:00:00",
"master_merchant_code": "BAOKIMMASTERMERCHANT",
"sub_merchant_code": "BAOKIMSUBMERCHANT",
"store_code": null,
"branch_code": null,
"staff_code": null,
"service_code": "BILLINTERNET",
"mrc_order_id": "BK_3894757",
"description": "Test Order",
"total_amount": 20000,
"url_success": "https://baokim.vn/success",
"url_fail": "https://baokim.vn/fail",
"save_token": 0,
"items": [
[
{
"code": "SP001",
"name": "Product 01",
"amount": 10000,
"quantity": 1,
"link": "https://baokim.vn/items/1"
},
{
"code": "SP002",
"name": "Product 02",
"amount": 10000,
"quantity": 1,
"link": "https://baokim.vn/items/2"
}
]
],
"customer_info": {
"code": "KH001",
"name": "Nguyen Van A",
"email": "[email protected]",
"phone": "0812345678",
"address": "313 Truong Chinh, Khuong Mai, Thanh Xuan, Ha Noi",
"gender": 1
},
"payment_info": {
"token": "Mq7AwLoHkafPdXYxvYedH8sb6MZ18k",
"card_hash": null
},
"payment_method": 22
}
Response
Main Parameters Table
| No. | Parameter | Data Type | Required | Description |
|---|---|---|---|---|
| 1 | code | Integer | ✅ | Result code: 100 = Processing, 101 = Redirect required |
| 2 | message | String | ✅ | Message |
| 3 | data | Object | ✅ | Returned data |
Data Information
| No. | Parameter | Data Type | Required | Description |
|---|---|---|---|---|
| 1 | order_id | Integer | ✅ | Baokim order ID |
| 2 | mrc_order_id | String | ✅ | Merchant's order ID |
| 3 | master_merchant_code | String | ✅ | Master merchant code |
| 4 | sub_merchant_code | String | ✅ | Sub merchant code |
| 5 | total_amount | Integer | ✅ | Total order amount |
| 6 | payment_method | Integer | ✅ | Payment method |
| 7 | created_at | Datetime | ✅ | Creation time |
| 8 | updated_at | Datetime | ✅ | Last update time |
| 9 | redirect_url | String | ❌ | Baokim payment link (has value when code = 101) |
Response Example — Redirect Required (code = 101)
{
"code": 101,
"message": "Success",
"data": {
"order_id": 50911,
"mrc_order_id": "BK_3894757",
"master_merchant_code": "BAOKIMMASTERMERCHANT",
"sub_merchant_code": "BAOKIMSUBMERCHANT",
"total_amount": 20000,
"payment_method": 22,
"created_at": "2025-04-14 15:23:10",
"updated_at": "2025-04-14 15:23:10",
"redirect_url": "https://b2b-payment-page.devtest.baokim.vn/payment/?oid=50911&checksum=50f1c60363c29c19b1c18359f1b4cfc655165117"
}
}
Response Example — Processing (code = 100)
{
"code": 100,
"message": "Transaction is being processed",
"data": {
"order_id": 50911,
"mrc_order_id": "BK_3894757",
"master_merchant_code": "BAOKIMMASTERMERCHANT",
"sub_merchant_code": "BAOKIMSUBMERCHANT",
"total_amount": 20000,
"payment_method": 22,
"created_at": "2025-04-14 15:23:10",
"updated_at": "2025-04-14 15:23:10",
"redirect_url": null
}
}
Error Codes
| Error Code | Description |
|---|---|
| 100 | Processing |
| 101 | Success - customer redirect required |
| 102 | Provider error |
| 104 | Authentication error |
| 707 | Order ID already exists |
| 709 | Master Merchant cannot create transaction on its own |
| 710 | Sub Merchant not found |
| 711 | Master Merchant not found |
| 712 | Sub Merchant inactive |
| 713 | Master Merchant inactive |
| 714 | Sub Merchant does not belong to Master Merchant |
| 717 | Service code not found |
| 718 | Service code inactive |
| 720 | Invalid token |
| 724 | Fee configuration not found |