1. Tải và cài đặt postman
Truy cập link //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:
//demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceWS/createInvoice/{supplierCode}
Ví dụ:
//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”:””,
“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:
02GTTT
02GTTT0/001
VND
1
true
TM
TM
true
user 1
Đặng thị thanh tâm
HN VN
11111
123456789
1
Đặng thị thanh tâm
0100109106-501
test
0123456789
vtbank
23423424
TM
1
ENGLISH_COURSE
Khóa học tiếng anh
khóa học
3500000
10
35000000
10
0
0
150000
35000000
35000000
3500000
38500000
Ba mươi tám triệu năm trăm nghìn đồng chẵn
0
0
10
10
35000000
3500000
[2] Hủy hóa đơn
- Api:
//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:
//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:
0100109106-968
< invoiceNo>AA/18E0000011
< pattern>02GTTT0/001
< fileType>ZIP
[4] Lấy file bản chuyển đổi
- Api:
//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