Chuyển tới nội dung chính

Khach hang

Quan ly ho so khach hang bao gom thong tin lien he, dia chi va tai khoan ngan hang.

Tham chieu nhanh

EndpointMethodMo ta
/api/v1/customersPOSTTao khach hang moi
/api/v1/customersGETLay danh sach tat ca khach hang
/api/v1/customers/:idGETLay thong tin khach hang cu the
/api/v1/customers/:idPUTCap nhat khach hang
/api/v1/customers/:idDELETEXoa khach hang

Cac endpoint API

Tao khach hang

Tao ban ghi khach hang moi.

POST /api/v1/customers
curl -X POST 'https://api.finan.one/open/api/v1/customers' \
-H 'Content-Type: application/json' \
-H 'x-client-id: YOUR_CLIENT_ID' \
-H 'x-signature: YOUR_SIGNATURE' \
-H 'x-timestamp: 1699999999' \
-d '{
"general_info": {
"name": "Nguyen Van B",
"customer_code": "CUST20231122",
"phone": "0933456789",
"phone_code": "+84",
"email": "[email protected]",
"type": "personal",
"tax_id": "123456789",
"contact_persons": [
{
"name": "Jane Smith",
"phone_number": "987654321",
"email": "[email protected]"
}
],
"custom_tag": "VIP"
},
"address": {
"country": "Vietnam",
"province": "Ho Chi Minh",
"district": "District 1",
"ward": "Ben Thanh Ward",
"address": "123 Le Loi Street",
"zip_code": "100000"
},
"bank_accounts": [
{
"bank_code": "201",
"bank_name": "Vietcombank",
"account_holder_name": "Nguyen Van B",
"account_number": "123456789012"
}
]
}'

Noi dung request

general_info (bat buoc)

TruongKieuBat buocMo ta
namestringHo ten khach hang
customer_codestringMa dinh danh khach hang duy nhat
phonestringSo dien thoai
phone_codestringMa quoc gia (vi du: +84)
emailstringDia chi email
typestringpersonal hoac company
tax_idstringMa so thue
contact_personsarrayNguoi lien he (bat buoc cho loai company)
custom_tagstringNhan tuy chinh (vi du: VIP)

contact_persons (bat buoc cho loai company)

TruongKieuBat buocMo ta
namestringTen nguoi lien he
phone_numberstringSo dien thoai lien he
emailstringEmail lien he

address (tuy chon)

TruongKieuMo ta
countrystringQuoc gia
provincestringTinh/Thanh pho
districtstringQuan/Huyen
wardstringPhuong/Xa
addressstringDia chi duong
zip_codestringMa buu chinh

bank_accounts (tuy chon)

TruongKieuMo ta
bank_codestringMa ngan hang. Xem Tai lieu tham chieu ma
bank_namestringTen ngan hang
account_holder_namestringTen chu tai khoan
account_numberstringSo tai khoan

Phan hoi

{
"message": { "content": "Thực thi API thành công" },
"code": 102001,
"request_id": "abc123...",
"data": {
"customer_id": "550e8400-e29b-41d4-a716-446655440000",
"general_info": {
"name": "Nguyen Van B",
"customer_code": "CUST20231122",
"phone": "0933456789",
"email": "[email protected]",
"type": "personal"
},
"address": {
"country": "Vietnam",
"province": "Ho Chi Minh",
"district": "District 1"
},
"bank_accounts": [
{
"bank_code": "201",
"bank_name": "Vietcombank",
"account_number": "123456789012"
}
],
"created_at": "2024-01-20T14:00:00Z"
}
}
mẹo

Dam bao customer_code la duy nhat trong he thong cua ban de tranh cac ban ghi trung lap.


Lay danh sach khach hang

Truy xuat tat ca khach hang.

GET /api/v1/customers
curl -X GET 'https://api.finan.one/open/api/v1/customers' \
-H 'Content-Type: application/json' \
-H 'x-client-id: YOUR_CLIENT_ID' \
-H 'x-signature: YOUR_SIGNATURE' \
-H 'x-timestamp: 1699999999'

Phan hoi

{
"message": { "content": "Thực thi API thành công" },
"code": 102000,
"request_id": "abc123...",
"data": [
{
"customer_id": "550e8400-e29b-41d4-a716-446655440000",
"general_info": {
"name": "Nguyen Van B",
"customer_code": "CUST20231122",
"type": "personal"
},
"created_at": "2024-01-20T14:00:00Z"
}
]
}
Lay mot khach hang
GET /api/v1/customers/:customer_id

Cap nhat khach hang

Thay the du lieu cua khach hang hien tai. Day la thao tac thay the toan bo -- tat ca cac truong bat buoc phai duoc bao gom, va cac truong tuy chon bi bo qua se bi xoa.

PUT /api/v1/customers/:customer_id
Thay the toan bo, khong phai cap nhat mot phan

Ban phai bao gom general_info.type va tat ca cac truong ban muon giu lai. Cac truong khong duoc bao gom (vi du: address, bank_accounts) se bi dat lai thanh trong.

curl -X PUT 'https://api.finan.one/open/api/v1/customers/550e8400-e29b-41d4-a716-446655440000' \
-H 'Content-Type: application/json' \
-H 'x-client-id: YOUR_CLIENT_ID' \
-H 'x-signature: YOUR_SIGNATURE' \
-H 'x-timestamp: 1699999999' \
-d '{
"general_info": {
"name": "Updated Customer Name",
"customer_code": "CUST20231122",
"phone": "0933456789",
"phone_code": "+84",
"email": "[email protected]",
"type": "personal",
"custom_tag": "Priority Customer"
},
"address": {
"country": "Vietnam",
"province": "Ho Chi Minh"
}
}'

Phan hoi

{
"message": { "content": "Thực thi API thành công" },
"code": 102000,
"request_id": "abc123...",
"data": {
"customer_id": "550e8400-e29b-41d4-a716-446655440000",
"general_info": {
"name": "Updated Customer Name",
"email": "[email protected]"
},
"updated_at": "2024-01-21T10:00:00Z"
}
}

Xoa khach hang

Xoa ban ghi khach hang.

DELETE /api/v1/customers/:customer_id
curl -X DELETE 'https://api.finan.one/open/api/v1/customers/550e8400-e29b-41d4-a716-446655440000' \
-H 'Content-Type: application/json' \
-H 'x-client-id: YOUR_CLIENT_ID' \
-H 'x-signature: YOUR_SIGNATURE' \
-H 'x-timestamp: 1699999999'

Phan hoi

{
"message": { "content": "Thực thi API thành công" },
"code": 102001,
"request_id": "abc123...",
"data": "success"
}
Phu thuoc

Viec xoa co the that bai neu khach hang con hoa don chua thanh toan hoac hop dong dang hoat dong. Hay giai quyet cac phu thuoc truoc.


Buoc tiep theo