E-Invoice
Tạo hóa đơn điện tử dễ dàng – Minh bạch tài chính tức thì
Cas E-Invoice API hỗ trợ tạo hóa đơn điện tử một cách nhanh chóng, chính xác và tự động, giúp đơn giản hóa quy trình kế toán và đảm bảo tuân thủ quy định tài chính. Bạn có thể:
-
Khởi tạo hóa đơn trực tiếp từ giao dịch hoặc dữ liệu bán hàng
-
Gửi hóa đơn điện tử đến người mua qua email hoặc link
-
Đồng bộ dữ liệu hóa đơn phục vụ báo cáo thuế, kế toán
-
Đảm bảo tính minh bạch và đối chiếu dễ dàng trong mọi hoạt động tài chính
Xem cấu trúc tạo hóa đơn mẫu
{
"invoiceCreationType": "ISSUED",
"invoiceType": "1",
"templateCode": "1/247",
"invoiceSeries": "K24TSA",
"currencyCode": "VND",
"adjustmentType": "1",
"paymentStatus": true,
"invoiceIssuedDate": 1749001176000,
"validation": 0,
"buyerInfo": {
"buyerNotGetInvoice": 0,
"buyerName": "Nguyen Van A",
"buyerLegalName": "CÔNG TY TNHH CASSO",
"buyerTaxCode": "0316794479",
"buyerAddressLine": "I.102D, Nhà A, Khu Công Nghệ Phần Mềm, Đường Nội Bộ Đại học Quốc Gia Thành Phố Hồ Chí Minh, Khu phố 6, Phường Linh Trung, Thành phố Thủ Đức, Thành phố Hồ Chí Minh, Việt Nam",
"buyerEmail": "[email protected]"
},
"taxBreakdowns": {
"taxPercentage": -2,
},
"items": [
{
"itemTotalAmountWithoutTax": 10000,
"itemName": "Phần mềm payOS - Gói ABC",
"unitName": "Gói",
"unitPrice": 10000,
"quantity": 1
}
],
"payments": [
{
"paymentMethod": "3",
"paymentMethodName": "TM/CK"
}
]
}
Các bước tích hợp E-Invoice
Dưới đây là các bước để tích hợp E-Invoice vào sản phẩm của bạn.
-
Tạo một phân quyền /grant/token với
scopes
có giá trị làinvoice
. -
Mở giao diện Cas Link bằng
grantToken
được trả về ở bước trên. Xem chi tiết -
Sau khi người dùng hoàn tất xác thực, phía giao diện của bạn sẽ nhận được một publicToken, dùng publicToken này để lấy accessToken cho phân quyền.
-
Bây giờ bạn đã có thể gọi API tạo hoá đơn.
Gọi API
Tạo phân quyền cho E-Invoice
- CURL
- Javascript (Axios)
curl --location 'https://sandbox.bankhub.dev/grant/token' \
--header 'X-BankHub-Api-Version: 2023-01-01' \
--header 'x-client-id: <CLIENT_ID_HERE>' \
--header 'x-secret-key: <SECRET_KEY_HERE>' \
--header 'Content-Type: application/json' \
--data '{
"scopes": "invoice",
"language": "vi",
"redirectUri": "https://your-domain.vn/link",
}'
const axios = require('axios');
const data = JSON.stringify({
"scopes": "invoice",
"language": "vi",
"redirectUri": "https://your-domain.vn/link",
});
const config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://sandbox.bankhub.dev/grant/token',
headers: {
'X-BankHub-Api-Version': '2023-01-01',
'x-client-id': '<CLIENT_ID_HERE>',
'x-secret-key': '<SECRET_KEY_HERE>',
'Content-Type': 'application/json',
},
data: data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
Xem chi tiết API, tại đây
Lấy accessToken từ publicToken
- CURL
- Javascript (Axios)
curl --location 'https://sandbox.bankhub.dev/grant/exchange' \
--header 'X-BankHub-Api-Version: 2023-01-01' \
--header 'x-client-id: <CLIENT_ID_HERE>' \
--header 'x-secret-key: <SECRET_KEY_HERE>' \
--header 'Content-Type: application/json' \
--data '{
"publicToken": "bdbde2bad-7685-4f95-987c-71309a4a3"
}'
const axios = require('axios');
const data = JSON.stringify({
"publicToken": "bdbde2bad-7685-4f95-987c-71309a4a3"
});
const config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://sandbox.bankhub.dev/grant/exchange',
headers: {
'X-BankHub-Api-Version': '2023-01-01',
'x-client-id': '<CLIENT_ID_HERE>',
'x-secret-key': '<SECRET_KEY_HERE>',
'Content-Type': 'application/json'
},
data: data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
Xem chi tiết API, tại đây
API tạo hoá đơn điện tử
- CURL
- Javascript (Axios)
curl --location 'https://sandbox.bankhub.dev/invoices' \
--header 'X-BankHub-Api-Version: 2023-01-01' \
--header 'Authorization: <ACCESS_TOKEN_HERE>' \
--header 'x-client-id: <CLIENT_ID_HERE>' \
--header 'x-secret-key: <SECRET_KEY_HERE>'
--data-raw '{
"invoiceCreationType": "ISSUED",
"invoiceType": "1",
"templateCode": "1/247",
"invoiceSeries": "K24TSA",
"currencyCode": "VND",
"adjustmentType": "1",
"paymentStatus": true,
"invoiceIssuedDate": 1749001176000,
"validation": 0,
"buyerInfo": {
"buyerNotGetInvoice": 0,
"buyerName": "Nguyen Van A",
"buyerLegalName": "CÔNG TY TNHH CASSO",
"buyerTaxCode": "0316794479",
"buyerAddressLine": "I.102D, Nhà A, Khu Công Nghệ Phần Mềm, Đường Nội Bộ Đại học Quốc Gia Thành Phố Hồ Chí Minh, Khu phố 6, Phường Linh Trung, Thành phố Thủ Đức, Thành phố Hồ Chí Minh, Việt Nam",
"buyerEmail": "[email protected]"
},
"taxBreakdowns": {
"taxPercentage": -2,
},
"items": [
{
"itemTotalAmountWithoutTax": 10000,
"itemName": "Phần mềm payOS - Gói ABC",
"unitName": "Gói",
"unitPrice": 10000,
"quantity": 1
}
],
"payments": [
{
"paymentMethod": "3",
"paymentMethodName": "TM/CK"
}
]
}'
const axios = require('axios');
let data = JSON.stringify({
"invoiceCreationType": "ISSUED",
"invoiceType": "01GTKT",
"templateCode": "1/247",
"invoiceSeries": "K24TSA",
"currencyCode": "VND",
"adjustmentType": "1",
"paymentStatus": true,
"invoiceIssuedDate": 0,
"buyerInfo": {
"buyerNotGetInvoice": false,
"buyerName": "string",
"buyerLegalName": "string",
"buyerTaxCode": "string",
"buyerAddressLine": "string",
"buyerEmail": "[email protected]"
},
"taxBreakdowns": {
"taxPercentage": 0,
"taxAmount": 0,
"taxableAmount": 0
},
"items": [
{
"itemTotalAmountWithoutTax": 0,
"itemTotalAmountWithTax": 0,
"taxAmount": 0,
"itemName": "string",
"unitName": "string",
"unitPrice": 0,
"quantity": 0
}
],
"payments": [
{
"paymentMethod": "string",
"paymentMethodName": "string"
}
],
"summarizeInfo": {
"totalTaxAmount": 0,
"totalAmountWithTax": 0,
"totalAmountWithoutTax": 0
},
"validation": false
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://sandbox.bankhub.dev/invoices',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'x-client-id': '<x-client-id>',
'x-secret-key': '<x-client-id>',
'Authorization': '<x-client-id>'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
Xem chi tiết API, tại đây