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

Hoa don

Tao va quan ly hoa don voi xu ly thanh toan tich hop.

Invoice Flow

Tham chieu nhanh

EndpointMethodMo ta
/api/v1/invoicesPOSTTao hoa don moi
/api/v1/invoicesGETLay danh sach tat ca hoa don
/api/v1/invoices/:idGETLay thong tin hoa don cu the
/api/v1/invoices/:idPUTCap nhat hoa don
/api/v1/invoices/:idDELETEXoa hoa don

Cac endpoint API

Tao hoa don

Tao hoa don moi voi san pham, khach hang va phuong thuc thanh toan.

POST /api/v1/invoices
curl -X POST 'https://api.finan.one/open/api/v1/invoices' \
-H 'Content-Type: application/json' \
-H 'x-client-id: YOUR_CLIENT_ID' \
-H 'x-signature: YOUR_SIGNATURE' \
-H 'x-timestamp: 1699999999' \
-d '{
"invoice_code": "INV12345",
"transaction_date": "2024-11-22T10:00:00Z",
"due_date": "2024-11-29T10:00:00Z",
"items": [
{
"code": "PRD0001",
"tax_code": "TAX_CODE_10",
"unit_price": 100000,
"quantity": 2,
"note": "note for product"
}
],
"tax_type": "price_excluding_tax",
"discount": {
"is_percentage": false,
"value": 10000
},
"customer": {
"code": "CUST123",
"email": "[email protected]"
},
"note": "This is a note for the invoice",
"payment_methods": ["bank_transfer", "card", "ewallet_momo"],
"account_id": "54957437-0cb5-4992-ad0e-76d26ba4ddc3"
}'

Noi dung request

TruongKieuBat buocMo ta
invoice_codestringMa hoa don duy nhat
transaction_datedatetimeNgay giao dich (ISO 8601)
due_datedatetimeNgay den han thanh toan (ISO 8601)
tax_typestringprice_excluding_tax, price_including_tax, hoac tax_not_applicable
itemsarrayDanh sach san pham/dich vu
customerobjectThong tin khach hang
discountobjectCau hinh giam gia
notestringGhi chu hoa don
payment_methodsarrayPhuong thuc thanh toan chap nhan: bank_transfer, card, ewallet_momo
account_iduuidBat buoc cho bank_transfer toi Shinhan. Lay tu API Tai khoan

items[]

TruongKieuBat buocMo ta
codestringMa SKU san pham
tax_codestringMa thue. Xem Tai lieu tham chieu ma
unit_priceintegerGia moi don vi (su dung gia san pham neu de trong)
quantityintegerSo luong
notestringGhi chu muc

discount

TruongKieuMo ta
is_percentagebooleanfalse cho so tien co dinh, true cho phan tram
valuefloatGia tri giam gia (toi da 2 chu so thap phan)

customer

TruongKieuBat buocMo ta
codestringMa khach hang (phai ton tai trong he thong)
emailstringGhi de email chi cho hoa don nay

Phan hoi

{
"message": { "content": "Thực thi API thành công" },
"code": 102001,
"request_id": "abc123...",
"data": {
"invoice_id": "INV-550e8400-e29b-41d4-a716-446655440000",
"invoice_code": "INV12345",
"transaction_date": "2024-11-22T10:00:00Z",
"due_date": "2024-11-29T10:00:00Z",
"tax_type": "price_excluding_tax",
"total_amount": 220000,
"total_tax_amount": 20000,
"total_discount_amount": 10000,
"paid_amount": 0,
"unpaid_amount": 220000,
"items": [
{
"code": "PRD0001",
"name": "Product Name",
"quantity": 2,
"unit_price": 100000,
"amount": 200000
}
],
"customer": {
"code": "CUST123",
"name": "Customer Name",
"email": "[email protected]"
},
"payment_link": "https://book.finan.one/pay/520/invoice/INV12345",
"created_at": "2024-11-22T12:00:00Z"
}
}
Lien ket thanh toan

Chia se payment_link voi khach hang cua ban de thanh toan de dang. Ho tro tat ca cac phuong thuc thanh toan da cau hinh.


Lay danh sach hoa don

Truy xuat tat ca hoa don.

GET /api/v1/invoices
curl -X GET 'https://api.finan.one/open/api/v1/invoices' \
-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": [
{
"invoice_id": "INV-550e8400-e29b-41d4-a716-446655440000",
"invoice_code": "INV12345",
"transaction_date": "2024-11-22T10:00:00Z",
"due_date": "2024-11-29T10:00:00Z",
"total_amount": 220000,
"paid_amount": 220000,
"unpaid_amount": 0,
"payment_link": "https://book.finan.one/pay/520/invoice/INV12345",
"created_at": "2024-11-22T12:00:00Z"
}
]
}
Lay mot hoa don
GET /api/v1/invoices/:invoice_id

Lay yeu cau thanh toan cho hoa don

De truy xuat cac yeu cau thanh toan cho hoa don, su dung API Thanh toan voi bo loc:

curl -X GET 'https://api.finan.one/open/api/v1/payments?reference_type=invoice&reference_id=INV-550e8400' \
-H 'Content-Type: application/json' \
-H 'x-client-id: YOUR_CLIENT_ID' \
-H 'x-signature: YOUR_SIGNATURE' \
-H 'x-timestamp: 1699999999'

Cap nhat hoa don

Cap nhat hoa don hien tai voi cac muc moi, giam gia, ngay den han hoac email khach hang.

PUT /api/v1/invoices/:invoice_id
curl -X PUT 'https://api.finan.one/open/api/v1/invoices/INVOICE_ID' \
-H 'Content-Type: application/json' \
-H 'x-client-id: YOUR_CLIENT_ID' \
-H 'x-signature: YOUR_SIGNATURE' \
-H 'x-timestamp: 1699999999' \
-d '{
"due_date": "2024-11-29T10:00:00Z",
"items": [
{
"code": "PRD0001",
"tax_code": "TAX_CODE_10",
"unit_price": 100000,
"quantity": 2,
"note": "note for product"
}
],
"discount": {
"is_percentage": false,
"value": 120000
},
"customer": {
"email": "[email protected]"
},
"note": "This is note of invoice"
}'

Cac truong co the cap nhat

TruongKieuMo ta
due_datedatetimeNgay den han da cap nhat
itemsarrayDanh sach muc da cap nhat
discountobjectGiam gia da cap nhat
customer.emailstringGhi de email khach hang
notestringGhi chu hoa don

Phan hoi

{
"message": { "content": "Thực thi API thành công" },
"code": 102000,
"request_id": "abc123...",
"data": {
"invoice_id": "INV-550e8400-e29b-41d4-a716-446655440000",
"invoice_code": "INV12345",
"due_date": "2024-12-05T10:00:00Z",
"total_amount": 330000,
"updated_at": "2024-11-23T10:00:00Z"
}
}

Xoa hoa don

Xoa mot hoa don.

DELETE /api/v1/invoices/:invoice_id
curl -X DELETE 'https://api.finan.one/open/api/v1/invoices/INV-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"
}
Yeu cau thanh toan

Neu hoa don co cac yeu cau thanh toan, chung van hoat dong sau khi xoa. Ban van co the truy van thanh toan bang reference_type=invoice va reference_id.


Buoc tiep theo