Gọi hàm web service như thế nào
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
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
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:
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
https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceWS/createInvoice/{supplierCode} Ví dụ: https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceWS/createInvoice/0100109106-968
{ “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”:””, “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 } ] }
(2) Hủy hóa đơn
https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceWS/cancelTransactionInvoice
supplierTaxCode=0100109106-968&invoiceNo=AA%2F18E0000011&strIssueDate=20180627081259&additionalReferenceDesc=hello&additionalReferenceDate=20180627081259 (3) Lấy file bản thể hiện
https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceUtilsWS/getInvoiceRepresentationFile
Content-type json: application/json Input json: { “supplierTaxCode”:”0100109106-968″, “invoiceNo”:”AA/18E0000011″, “pattern”:”02GTTT0/001″, “fileType”:”ZIP” }
Content-type xml: application/xml Input xml: < invoiceNo>AA/18E0000011 < pattern>02GTTT0/001 < fileType>ZIP (4) Lấy file bản chuyển đổi
https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceWS/createExchangeInvoiceFile
supplierTaxCode=0100109106-968&invoiceNo=AA%2F18E0000010&strIssueDate=20180627081259&exchangeUser=%C4%90%E1%BA%B7ng%20T.T%20T%C3%A2m |