Hướng Dẫn Sử Dụng

35. Sử dụng Postman gọi API webservice hóa đơn điện tử

1. Tải và cài đặt postman

Truy cập link https://www.getpostman.com/apps, chọn tải postman tương ứng với hệ điều hành của máy tính đang dùng

2. Các bước gọi một API

  • Bước 1: Chạy postman, Chọn New > Create new request

  • Bước 2: nhập tên, chọn thư mục lưu

  • Bước 3: Nhập các tham số

Tab Authorization: Nhập user/pass

Tab Header: Nhập nội dung content-type, accept

Tab Body: chọn raw (input là json) hoặc x-www-form-urlencoded

  • Bước 4: gửi request và nhận kết quả trả về

3. Các lỗi thường gặp

Với mỗi user, hệ thống chỉ cho phép một vài địa chỉ IP nhất định truy cập đến web service. IP phải là IP public của hệ thống đối tác. Để cập nhật IP, người dùng có thể tự cập nhật thông qua các bước như sau:

  • Bước 1: Vào hệ thống trên web, sử dụng đúng acc đang sử dụng để tích hợp
  • Bước 2: Vào chức năng: Quản lý thông tin doanh nghiệp/ Quản lý người dùng
  • Bước 3: Tìm đến user cần add IP, chọn buttom Cập nhật
  • Bước 4: Trên màn hình cập nhật thông tin, trường thông tin địa chỉ IP được khai báo theo quy định như sau: Các IP liên tiếp phân cách bằng ký tự |.

Ví dụ: 2.2.2.2|3.3.3.3|4.4.4.4

Bất cứ trường hợp nào sai tài khoản/mật khẩu hay IP sẽ nhận về kết quả trả về là 500 Request Fail

4. Tham số đầu vào các api mẫu

      (1) Lập hóa đơn

  • Api:

https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceWS/createInvoice/{supplierCode}

Ví dụ:

https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceWS/createInvoice/0100109106-968

  • Method: POST
  • Content-type json: application/json
  • Input json:

{

“generalInvoiceInfo”:{

“invoiceType”:”02GTTT”,

“templateCode”:”02GTTT0/001″,

“currencyCode”:”VND”,

“adjustmentType”:”1″,

“paymentStatus”:true,

“paymentType”:”TM”,

“paymentTypeName”:”TM”,

“cusGetInvoiceRight”:true,

“userName”:”user 1″

},

“buyerInfo”:{

“buyerName”:”Đặng thị thanh tâm”,

“buyerLegalName”:””,

“buyerTaxCode”:””,

“buyerAddressLine”:”HN VN”,

“buyerPhoneNumber”:”11111″,

“buyerEmail”:””,

“buyerIdNo”:”123456789″,

“buyerIdType”:”1″

},

“sellerInfo”:{

“sellerLegalName”:”Đặng thị thanh tâm”,

“sellerTaxCode”:”0100109106-501″,

“sellerAddressLine”:”test”,

“sellerPhoneNumber”:”0123456789″,

“sellerEmail”:”PerformanceTest1@viettel.com.vn”,

“sellerBankName”:”vtbank”,

“sellerBankAccount”:”23423424″

},

“payments”:[

{

“paymentMethodName”:”TM”

}

],

“itemInfo”:[

{

“lineNumber”:1,

“itemCode”:”ENGLISH_COURSE”,

“itemName”:”Khóa học tiếng anh”,

“unitName”:”khóa học”,

“unitPrice”:3500000.0,

“quantity”:10.0,

“itemTotalAmountWithoutTax”:35000000,

“taxPercentage”:10.0,

“taxAmount”:0.0,

“discount”:0.0,

“itemDiscount”:150000.0

}

],

“summarizeInfo”:{

“sumOfTotalLineAmountWithoutTax”:35000000,

“totalAmountWithoutTax”:35000000,

“totalTaxAmount”:3500000.0,

“totalAmountWithTax”:38500000,

“totalAmountWithTaxInWords”:”Ba mươi tám triệu năm trăm nghìn đồng chẵn”,

“discountAmount”:0.0,

“settlementDiscountAmount”:0.0,

“taxPercentage”:10.0

},

“taxBreakdowns”:[

{

“taxPercentage”:10.0,

“taxableAmount”:35000000,

“taxAmount”:3500000.0

}

]

}

  • Content-type xml: application/xml
  • Input xml:

<?xml version=”1.0″ encoding=”UTF-8″ ?>

<commonDataInput>

<generalInvoiceInfo>

<invoiceType>02GTTT</invoiceType>

<templateCode>02GTTT0/001</templateCode>

<currencyCode>VND</currencyCode>

<adjustmentType>1</adjustmentType>

<paymentStatus>true</paymentStatus>

<paymentType>TM</paymentType>

<paymentTypeName>TM</paymentTypeName>

<cusGetInvoiceRight>true</cusGetInvoiceRight>

<userName>user 1</userName>

</generalInvoiceInfo>

<buyerInfo>

<buyerName>Đặng thị thanh tâm</buyerName>

<buyerLegalName></buyerLegalName>

<buyerTaxCode></buyerTaxCode>

<buyerAddressLine>HN VN</buyerAddressLine>

<buyerPhoneNumber>11111</buyerPhoneNumber>

<buyerEmail></buyerEmail>

<buyerIdNo>123456789</buyerIdNo>

<buyerIdType>1</buyerIdType>

</buyerInfo>

<sellerInfo>

<sellerLegalName>Đặng thị thanh tâm</sellerLegalName>

<sellerTaxCode>0100109106-501</sellerTaxCode>

<sellerAddressLine>test</sellerAddressLine>

<sellerPhoneNumber>0123456789</sellerPhoneNumber>

<sellerEmail>PerformanceTest1@viettel.com.vn</sellerEmail>

<sellerBankName>vtbank</sellerBankName>

<sellerBankAccount>23423424</sellerBankAccount>

</sellerInfo>

<payments>

<paymentMethodName>TM</paymentMethodName>

</payments>

<itemInfo>

<lineNumber>1</lineNumber>

<itemCode>ENGLISH_COURSE</itemCode>

<itemName>Khóa học tiếng anh</itemName>

<unitName>khóa học</unitName>

<unitPrice>3500000</unitPrice>

<quantity>10</quantity>

<itemTotalAmountWithoutTax>35000000</itemTotalAmountWithoutTax>

<taxPercentage>10</taxPercentage>

<taxAmount>0</taxAmount>

<discount>0</discount>

<itemDiscount>150000</itemDiscount>

</itemInfo>

<summarizeInfo>

<sumOfTotalLineAmountWithoutTax>35000000</sumOfTotalLineAmountWithoutTax>

<totalAmountWithoutTax>35000000</totalAmountWithoutTax>

<totalTaxAmount>3500000</totalTaxAmount>

<totalAmountWithTax>38500000</totalAmountWithTax>

<totalAmountWithTaxInWords>Ba mươi tám triệu năm trăm nghìn đồng chẵn</totalAmountWithTaxInWords>

<discountAmount>0</discountAmount>

<settlementDiscountAmount>0</settlementDiscountAmount>

<taxPercentage>10</taxPercentage>

</summarizeInfo>

<taxBreakdowns>

<taxPercentage>10</taxPercentage>

<taxableAmount>35000000</taxableAmount>

<taxAmount>3500000</taxAmount>

</taxBreakdowns>

</commonDataInput>

      (2) Hủy hóa đơn

  • Api:

https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceWS/cancelTransactionInvoice

  • Method: POST
  • Content-type: application/x-www-form-urlencoded
  • Input:

supplierTaxCode=0100109106-968&invoiceNo=AA%2F18E0000011&strIssueDate=20180627081259&additionalReferenceDesc=hello&additionalReferenceDate=20180627081259

     (3) Lấy file bản thể hiện

  • Api:

https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceUtilsWS/getInvoiceRepresentationFile

  • Method: POST
  • Đầu vào json:

Content-type json: application/json

Input json:

{

“supplierTaxCode”:”0100109106-968″,

“invoiceNo”:”AA/18E0000011″,

“pattern”:”02GTTT0/001″,

“fileType”:”ZIP”

}

  • Đầu vào xml:

Content-type xml: application/xml

Input xml:

<?xml version=”1.0″ encoding=”UTF-8″ ?>

<commonDataInput>

<supplierTaxCode>0100109106-968</supplierTaxCode>

< invoiceNo>AA/18E0000011</invoiceNo >

< pattern>02GTTT0/001</ pattern >

< fileType>ZIP</fileType >

</commonDataInput>

      (4) Lấy file bản chuyển đổi

  • Api:

https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceWS/createExchangeInvoiceFile

  • Method: POST
  • Content-type: application/x-www-form-urlencoded
  • Input:

supplierTaxCode=0100109106-968&invoiceNo=AA%2F18E0000010&strIssueDate=20180627081259&exchangeUser=%C4%90%E1%BA%B7ng%20T.T%20T%C3%A2m