Skip to content

Invoice Message Query

Query the e-invoice processing messages a T-VAN provider holds for a given invoice.

No authenticity validation

T-VAN's only invoice capability is listing invoice messages. It does not verify invoice authenticity with CQT, and there is no validateInvoice operation.

Overview

FeatureDescription
ServiceTVanService.queryInvoiceMessages()
Data SourceT-VAN provider (e.g. VNPAY)
Use CaseInspect invoice processing status / messages

Use Cases

  • Retrieve the processing messages returned for a submitted invoice
  • Inspect provider/CQT status codes and reason notes per message
  • Paginate through large message sets

Query Invoice Messages

typescript
import { TVanService } from '@nx/t-van';

async listInvoiceMessages() {
  const response = await this.tvanService.queryInvoiceMessages({
    provider: 'vnpay',
    params: {
      messageTypeCode: 200,
      messageCode: 'V0102182292A68308EFF92148B0A26',
      taxPayerTaxCode: '1801545696-999',
      invoiceNumberSymbol: '1',
      invoiceSymbol: 'C22THC',
      invoiceNumber: 13,
      invoiceIssuerTaxCode: '0101352495',
      fromDate: '2022-04-25T14:00:00',
      toDate: '2022-04-26T14:00:00',
      page: 0,
      size: 10,
    },
    options: { fetchAll: false },
  });

  return response.messages;
}

Response Structure

json
{
  "messages": [
    {
      "id": 3,
      "invoiceNumberSymbol": "1",
      "invoiceSymbol": "C22TPP",
      "messageTypeCode": 200,
      "messageCode": "V03123038035DE0AA1AC6C34EBAA03F54BD026AA35B",
      "responseMessageCode": "V03123038035DE0AA1AC6C34EBAA03F54BD026AA35B",
      "invoiceIssuerTaxCode": "0101352495",
      "invoiceNumber": 262,
      "taxPayerTaxCode": "0102182292-998",
      "taxDepartmentCode": "-1",
      "invoiceCreatedAt": "2024-01-01T00:00:00",
      "status": 5,
      "information": "Nhận thông tin lỗi từ tổng cục thuế",
      "reason": "02-CTS không phải do nhà CA cung cấp",
      "createdAt": "2024-01-01T00:00:00"
    }
  ],
  "currentPage": 0,
  "pageSize": 10,
  "totalPages": 5,
  "totalItems": 50
}

The status field is a provider-defined numeric code; interpret it against the provider's documentation.

Fetch All Pages

Pass options.fetchAll = true to auto-aggregate every page into a single messages array (the service walks totalPages for you):

typescript
const response = await this.tvanService.queryInvoiceMessages({
  provider: 'vnpay',
  params,
  options: { fetchAll: true },
});

Query Flow

REST API

http
GET /t-van/invoices?provider=vnpay&messageTypeCode=200&messageCode=V0102182292A68308EFF92148B0A26&taxPayerTaxCode=1801545696-999&invoiceNumberSymbol=1&invoiceSymbol=C22THC&invoiceNumber=13&invoiceIssuerTaxCode=0101352495&fromDate=2022-04-25T14:00:00&toDate=2022-04-26T14:00:00&page=0&size=10

Error Handling

Failures are surfaced from the provider response (HTTP status + provider error payload). Inspect the provider response and service logs:

typescript
try {
  const response = await this.tvanService.queryInvoiceMessages({ provider: 'vnpay', params });
  return response.messages;
} catch (error) {
  this.logger.error('[listInvoiceMessages] T-VAN query failed: %s', error);
  throw error;
}

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.