Barverkauf (fiskaltrust)
This commit is contained in:
@@ -26,7 +26,17 @@ Public Class cFiskaltrustClient
|
||||
Public Async Function SignReceiptAsync(amount As Double, vat As Double, POS As List(Of EABelegPositionen)) As Task(Of String)
|
||||
|
||||
Dim payload = BuildPayload(amount, vat, POS)
|
||||
Dim endpoint = GetEndpoint()
|
||||
Dim endpoint = GetEndpoint("payment")
|
||||
|
||||
Return Await SendAsync(endpoint, payload)
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Public Async Function Echo() As Task(Of String)
|
||||
|
||||
Dim payload = "TEST"
|
||||
Dim endpoint = GetEndpoint("test")
|
||||
|
||||
Return Await SendAsync(endpoint, payload)
|
||||
|
||||
@@ -44,7 +54,7 @@ Public Class cFiskaltrustClient
|
||||
.ftReceiptCase = 4919338172267102210 ' Storno
|
||||
}
|
||||
|
||||
Return Await SendAsync(GetEndpoint(), payload)
|
||||
Return Await SendAsync(GetEndpoint("payment"), payload)
|
||||
|
||||
End Function
|
||||
|
||||
@@ -69,7 +79,12 @@ Public Class cFiskaltrustClient
|
||||
request.Headers.Add("cashboxid", _cashboxId)
|
||||
request.Headers.Add("accesstoken", _accessToken)
|
||||
|
||||
request.Content = New StringContent(json, Encoding.UTF8, "application/json")
|
||||
Select Case _country
|
||||
Case "AT"
|
||||
request.Content = New StringContent(json, Encoding.UTF8, "text/xml")
|
||||
Case Else
|
||||
request.Content = New StringContent(json, Encoding.UTF8, "application/json")
|
||||
End Select
|
||||
|
||||
Dim response = Await _httpClient.SendAsync(request)
|
||||
Dim result = Await response.Content.ReadAsStringAsync()
|
||||
@@ -101,17 +116,22 @@ Public Class cFiskaltrustClient
|
||||
|
||||
End Try
|
||||
|
||||
If exToThrow IsNot Nothing Then
|
||||
Await Task.Delay(1000) ' ✅ jetzt OK
|
||||
Throw exToThrow
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
|
||||
If exToThrow IsNot Nothing Then
|
||||
Await Task.Delay(1000) ' ✅ jetzt OK
|
||||
Throw exToThrow
|
||||
End If
|
||||
|
||||
Throw New Exception("Unexpected error")
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
|
||||
' ================================
|
||||
' PAYLOAD BUILDER
|
||||
' ================================
|
||||
@@ -156,15 +176,37 @@ Public Class cFiskaltrustClient
|
||||
' ================================
|
||||
' ENDPOINT SWITCH
|
||||
' ================================
|
||||
Private Function GetEndpoint() As String
|
||||
Select Case _country
|
||||
Case "DE"
|
||||
Return "/json/v1/Sign"
|
||||
Case "AT"
|
||||
Return "/json/Sign"
|
||||
Case Else
|
||||
Throw New Exception("Unsupported country")
|
||||
End Select
|
||||
Private Function GetEndpoint(type As String) As String
|
||||
|
||||
If type = "payment" Then
|
||||
|
||||
|
||||
Select Case _country
|
||||
Case "DE"
|
||||
Return "/json/v1/Sign"
|
||||
Case "AT"
|
||||
Return "/json/Sign"
|
||||
Case Else
|
||||
Throw New Exception("Unsupported country")
|
||||
End Select
|
||||
|
||||
ElseIf type = "test" Then
|
||||
|
||||
Select Case _country
|
||||
Case "DE"
|
||||
Return "/json/v1/Echo"
|
||||
Case "AT"
|
||||
Return "/json/Echo"
|
||||
Case Else
|
||||
Throw New Exception("Unsupported country")
|
||||
End Select
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
' ================================
|
||||
|
||||
Reference in New Issue
Block a user