Barverkauf (fiskaltrust)

This commit is contained in:
2026-03-27 13:01:23 +01:00
parent ddae3769d0
commit fb60e8d342
3 changed files with 100 additions and 18 deletions

View File

@@ -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
' ================================