Kasi je dodijeljena fixna ip adresa i kad posaljem slijedeci kod za izdavanje racuna (OBUKA) sve prodje ok. Medjutim nikako ne mogu racun poslati na POS printer.
Code:
Private Sub Command14_Click()
Dim http As Object
Dim url As String
Dim body As String
Dim response As String
' Definišite URL
url = "http://192.168.1.21:3566/api/invoices"
' Kreirajte XMLHTTP objekat
Set http = CreateObject("MSXML2.ServerXMLHTTP.6.0")
' Definišite telo zahteva kao JSON string sa jednim artiklom i jednim načinom plačanja
body = "{""print"": true, ""email"": ""
[email protected]"", ""invoiceRequest"": {""invoiceType"": ""Training"", ""transactionType"": ""Sale"", ""payment"": [{""amount"": 0.10, ""paymentType"": ""0""}], ""items"": [{""name"": ""KESA TREGERICA"", ""labels"": [""E""], ""totalAmount"": 0.10, ""unitPrice"": 0.05, ""quantity"": 2.000}], ""cashier"": """"}}"
' Otvorite HTTP konekciju
http.Open "POST", url, False
' Dodajte zaglavlja
http.setRequestHeader "Authorization", "Bearer 4b0920000000000caccdfa5b57eb23f3"
http.setRequestHeader "RequestId", "19345"
http.setRequestHeader "Content-Type", "application/json"
' Pošaljite zahtev
http.send body
' Dobijte odgovor
response = http.responseText
' Prikažite odgovor
MsgBox response
Debug.Print response
' Oslobodite resurse
Set http = Nothing
End Sub
Posaljem i postavke ali opet ne mogu natjerati pos printer da stampa.
Code:
Private Sub Command23_Click()
Dim http As Object
Dim url As String
Dim body As String
Dim response As String
' Definišite URL za konfiguraciju štampača
url = "http://192.168.1.21:3566/api/settings"
' Kreirajte XMLHTTP objekat
Set http = CreateObject("MSXML2.ServerXMLHTTP.6.0")
' Definišite telo zahteva kao JSON string
body = "{""printerName"": ""EPSON TM-T88V Receipt"", " & _
"""printerType"": ""EscPos"", " & _
"""receiptWidth"": 576, " & _
"""receiptLayout"": ""Slip"", " & _
"""receiptFontSizeNormal"": 25, " & _
"""receiptFontSizeLarge"": 30, " & _
"""receiptHeaderImage"": false, " & _
"""receiptFooterImage"": false, " & _
"""receiptFeedLinesBegin"": 0, " & _
"""receiptFeedLinesEnd"": 3, " & _
"""receiptCutPaper"": ""CutPaper"", " & _
"""receiptOpenCashDrawer"": ""None"", " & _
"""qrCodeSize"": 400}"
' Otvorite HTTP konekciju
http.Open "POST", url, False
' Dodajte zaglavlja
http.setRequestHeader "Authorization", "Bearer 4b092000009c148caccdf00000eb23f3"
http.setRequestHeader "Content-Type", "application/json; charset=utf-8"
http.setRequestHeader "Content-Length", Len(body)
' Pošaljite zahtev
http.send body
' Dobijte odgovor
response = http.responseText
' Prikažite odgovor
MsgBox response
Debug.Print response
' Oslobodite resurse
Set http = Nothing
End Sub
Unaprijed hvala. Svaki savjet bi dobro dosao.
Amela.