API Giả lập giao dịch
API tạo giao dịch giả lập trong môi trường sandbox để test luồng nhận giao dịch và webhook.
API Endpoint
POST
https://bankhub-api-sandbox.sepay.vn/v1/transaction/createRequest Body
bank_account_xidstringrequired
ID tài khoản ngân hàng
transfer_typeenumrequired
Loại giao dịch (credit = tiền vào, debit = tiền ra)
amountnumberrequired
Số tiền giao dịch (VND)
transaction_contentstringrequired
Nội dung giao dịch
Lưu ý
- Chỉ sử dụng trong môi trường Sandbox
- Giao dịch giả lập sẽ được dùng để test webhook và luồng xử lý giao dịch
- Trường
transfer_typedùng để phân biệt tiền vào (in) và tiền ra (out)
Xử lý lỗi
400Validation ErrorDữ liệu đầu vào không hợp lệ
401UnauthorizedAccess token không hợp lệ hoặc đã hết hạn
403ForbiddenAPI này chỉ khả dụng trên môi trường Sandbox
API Response
Response 200 - Tạo thành công
{
"code": 201,
"message": "string",
"data": {
"transaction_id": "string",
"reference_number": "string",
"transaction_date": "string",
"amount": 0,
"transfer_type": "string",
"accumulated": 0
}
}codeinteger
Mã trạng thái HTTP
messagestring
Thông báo kết quả
dataobject
Dữ liệu giao dịch giả lập
Code mẫu
>
>
>
>
>
curl --request POST \--url https://bankhub-api-sandbox.sepay.vn/v1/transaction/create \--header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \--header 'content-type: application/json' \--data '{"bank_account_xid":"52930e2b-c38b-4cd1-b2a2-9ddcdc603104","transfer_type":"credit","amount":0,"transaction_content":"string"}'
Ví dụ sử dụng
JSTạo giao dịch tiền vào
1
2
3
4
5
6
7
8
9
curl --location 'https://bankhub-api-sandbox.sepay.vn/v1/transaction/create' \--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \--header 'Content-Type: application/json' \--data '{"bank_account_xid": "ba_abc123xyz","transfer_type": "in","amount": 500000,"transaction_content": "Thanh toan DH123456"}'
JSTạo giao dịch tiền ra
1
2
3
4
5
6
7
8
9
curl --location 'https://bankhub-api-sandbox.sepay.vn/v1/transaction/create' \--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \--header 'Content-Type: application/json' \--data '{"bank_account_xid": "ba_abc123xyz","transfer_type": "out","amount": 100000,"transaction_content": "Chuyen khoan"}'
Webhook
- Sau khi tạo giao dịch giả lập, webhook giao dịch sẽ được gửi đến endpoint của bạn nếu đã cấu hình
- Xem hướng dẫn cấu hình webhook tại đây
Chỉ dùng trên Sandbox
API này chỉ khả dụng trên môi trường Sandbox. Nếu gọi trên Production sẽ nhận được lỗi 403 Forbidden.