summaryrefslogtreecommitdiff
path: root/simulation/sim-terminal.go
diff options
context:
space:
mode:
Diffstat (limited to 'simulation/sim-terminal.go')
-rw-r--r--simulation/sim-terminal.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/simulation/sim-terminal.go b/simulation/sim-terminal.go
index fe62c43..a639fc8 100644
--- a/simulation/sim-terminal.go
+++ b/simulation/sim-terminal.go
@@ -13,8 +13,10 @@ import (
const TERMINAL_PROVIDER = "Simulation"
+const TERMINAL_ID = "1"
+
// retrieved from the cli tool when added the terminal
-const TERMINAL_USER_ID = TERMINAL_PROVIDER + "-1"
+const TERMINAL_USER_ID = TERMINAL_PROVIDER + "-" + TERMINAL_ID
// retrieved from the cli tool when added the terminal
const TERMINAL_ACCESS_TOKEN = "secret"
@@ -36,7 +38,7 @@ func Terminal(in chan *SimulatedPhysicalInteraction, out chan *SimulatedPhysical
kill <- err
}
- wopid := base64.URLEncoding.EncodeToString(wopidBytes)
+ wopid := FormatWopid(wopidBytes)
fmt.Println("TERMINAL: Generated Nonce (base64 url encoded):", wopid)
uri := QR_CODE_CONTENT_BASE + wopid
fmt.Println("TERMINAL: Taler Withdrawal URI:", uri)
@@ -84,23 +86,30 @@ func Terminal(in chan *SimulatedPhysicalInteraction, out chan *SimulatedPhysical
for {
select {
case w := <-awaitSelection:
- fmt.Println("TERMINAL: selected parameter:", w.ReservePubKey)
+ fmt.Println("TERMINAL: parameters selected:", w.ReservePubKey)
if !DISABLE_DELAYS {
fmt.Println("TERMINAL: simulating user interaction. customer presents card. delay:", TERMINAL_ACCEPT_CARD_DELAY_MS)
- time.Sleep(time.Duration(TERMINAL_ACCEPT_CARD_DELAY_MS))
+ time.Sleep(time.Duration(TERMINAL_ACCEPT_CARD_DELAY_MS) * time.Millisecond)
} else {
fmt.Println("TERMINAL: simulating user interaction. customer presents card.")
}
if !DISABLE_DELAYS {
fmt.Println("TERMINAL: card accepted. terminal waits for response of provider backend. delay:", PROVIDER_BACKEND_PAYMENT_DELAY_MS)
- time.Sleep(time.Duration(PROVIDER_BACKEND_PAYMENT_DELAY_MS))
+ time.Sleep(time.Duration(PROVIDER_BACKEND_PAYMENT_DELAY_MS) * time.Millisecond)
} else {
fmt.Println("TERMINAL: card accepted. terminal waits for response of provider backend.")
}
+ terminalId, err := strconv.Atoi(TERMINAL_ID)
+ if err != nil {
+ fmt.Println("failed parsing the terminal id.")
+ kill <- err
+ }
+
fmt.Println("TERMINAL: payment was processed at the provider backend. sending payment notification.")
paymentNotification := &C2ECPaymentNotification{
ProviderTransactionId: "simulation-transaction-id-0",
+ TerminalId: terminalId,
Amount: Amount{
Currency: "CHF",
Fraction: 10,