Skip to main content

TVAN

Send e-invoice messages to the TVAN system for processing and forwarding to the tax authority.

Steps to Integrate TVAN​

Below are the steps to integrate TVAN into your product.

  1. Create a grant /grant/token with scopes set to invoice.
  • taxDeclaration (optional): the e-invoice usage registration form details, used to pre-fill the X-Invoice registration form in Cas ID when the user registers. See details
  1. Open the Cas Link interface using the grantToken returned in the previous step and select the X-Invoice service. See details

  2. After the user completes authentication, your frontend will receive a publicToken. Use this publicToken to obtain an accessToken for the grant.

  3. You can now call the Send Message API.

Registration form details (taxDeclaration)​

taxDeclaration is an optional field when creating a grant, applicable to the X-Invoice service. If your system already holds the customer's e-invoice usage registration details, pass them in so that Cas ID can pre-fill the registration form (form 01/ĐKTĐ-HĐĐT), and the user does not have to re-enter them.

FieldTypeDescription
emailstringContact email
registrationTypenumberForm type: 1 - New registration, 2 - Change of information
invoiceTypestring[]Invoice form: WITH_TAX_AUTHORITY_CODE - With tax authority code, FROM_POS - Invoice generated from a cash register
invoiceUsageTypestring[]Type of invoice used: VAT - Value-added tax invoice, SALE - Sales invoice
note

For any field you do not pass, Cas ID uses the default value or leaves it blank for the user to fill in.

Call API​

Create access grant for TVAN​

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",
"fiServiceId": "6d325840-00d7-11f1-af82-fa163e5398eb",
"taxDeclaration": {
"email": "nguyenvana@gmail.com",
"registrationType": 1,
"invoiceType": ["WITH_TAX_AUTHORITY_CODE"],
"invoiceUsageType": ["VAT"]
}
}'
info

For API details, see here

Get accessToken from publicToken​

  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"
}'
info

For API details, see here

API to send e-invoice messages to the TVAN system for processing and forwarding to the tax authority​

  curl --location 'https://sandbox.bankhub.dev/tvan/send' \
--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 '{
"xmlData": [
{
"xml": "<HDon></HDon>"
}
],
"xmlCount": 1,
"messageTypeCode": 206
}'
info

For API details, see here