gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-cashless2ecash] branch master updated: fix: set terminal id


From: gnunet
Subject: [taler-cashless2ecash] branch master updated: fix: set terminal id
Date: Wed, 08 May 2024 15:19:05 +0200

This is an automated email from the git hooks/post-receive script.

joel-haeberli pushed a commit to branch master
in repository cashless2ecash.

The following commit(s) were added to refs/heads/master by this push:
     new 513fa3e  fix: set terminal id
513fa3e is described below

commit 513fa3ee34e631fa1e483b0e76ec5df5b19f1bd5
Author: Joel-Haeberli <haebu@rubigen.ch>
AuthorDate: Wed May 8 15:19:00 2024 +0200

    fix: set terminal id
---
 c2ec/api-terminals.go | 12 ++++++++++--
 c2ec/db-postgres.go   |  7 +++++--
 c2ec/db.go            |  1 +
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/c2ec/api-terminals.go b/c2ec/api-terminals.go
index 83ceabf..61a3037 100644
--- a/c2ec/api-terminals.go
+++ b/c2ec/api-terminals.go
@@ -97,6 +97,13 @@ func handleWithdrawalSetup(res http.ResponseWriter, req 
*http.Request) {
                return
        }
 
+       terminalId := parseTerminalId(req)
+       if terminalId == -1 {
+               LogWarn("terminals-api", "terminal id could not be read from 
authorization header")
+               res.WriteHeader(HTTP_BAD_REQUEST)
+               return
+       }
+
        // generate wopid
        generatedWopid := make([]byte, 32)
        _, err = rand.Read(generatedWopid)
@@ -110,6 +117,7 @@ func handleWithdrawalSetup(res http.ResponseWriter, req 
*http.Request) {
                generatedWopid,
                preventNilAmount(setup.SuggestedAmount),
                preventNilAmount(setup.Amount),
+               terminalId,
                setup.ProviderTransactionId,
                preventNilAmount(setup.TerminalFees),
                setup.RequestUid,
@@ -152,7 +160,7 @@ func handleWithdrawalCheck(res http.ResponseWriter, req 
*http.Request) {
        wopid := req.PathValue(WOPID_PARAMETER)
        wpd, err := ParseWopid(wopid)
        if err != nil {
-               LogWarn("bank-integration-api", "wopid "+wopid+" not valid")
+               LogWarn("terminals-api", "wopid "+wopid+" not valid")
                if wopid == "" {
                        res.WriteHeader(HTTP_BAD_REQUEST)
                        return
@@ -167,7 +175,7 @@ func handleWithdrawalCheck(res http.ResponseWriter, req 
*http.Request) {
                return
        }
 
-       LogInfo("bank-integration-api", "received payment notification")
+       LogInfo("terminals-api", "received payment notification")
 
        terminalId := parseTerminalId(req)
        if terminalId == -1 {
diff --git a/c2ec/db-postgres.go b/c2ec/db-postgres.go
index 34c63cf..384022d 100644
--- a/c2ec/db-postgres.go
+++ b/c2ec/db-postgres.go
@@ -18,8 +18,9 @@ import (
 const PS_INSERT_WITHDRAWAL = "INSERT INTO " + WITHDRAWAL_TABLE_NAME + " (" +
        WITHDRAWAL_FIELD_NAME_WOPID + ", " + WITHDRAWAL_FIELD_NAME_RUID + ", " +
        WITHDRAWAL_FIELD_NAME_SUGGESTED_AMOUNT + ", " + 
WITHDRAWAL_FIELD_NAME_AMOUNT + ", " +
-       WITHDRAWAL_FIELD_NAME_TRANSACTION_ID + ", " + 
WITHDRAWAL_FIELD_NAME_FEES + ", " + WITHDRAWAL_FIELD_NAME_TS +
-       ") VALUES ($1,$2,($3,$4,$5),($6,$7,$8),$9,($10,$11,$12),$13)"
+       WITHDRAWAL_FIELD_NAME_TRANSACTION_ID + ", " + 
WITHDRAWAL_FIELD_NAME_FEES + ", " +
+       WITHDRAWAL_FIELD_NAME_TS + ", " + WITHDRAWAL_FIELD_NAME_TERMINAL_ID +
+       ") VALUES ($1,$2,($3,$4,$5),($6,$7,$8),$9,($10,$11,$12),$13,$14)"
 
 const PS_REGISTER_WITHDRAWAL_PARAMS = "UPDATE " + WITHDRAWAL_TABLE_NAME + " 
SET (" +
        WITHDRAWAL_FIELD_NAME_RESPUBKEY + "," +
@@ -231,6 +232,7 @@ func (db *C2ECPostgres) SetupWithdrawal(
        wopid []byte,
        suggestedAmount Amount,
        amount Amount,
+       terminalId int,
        providerTransactionId string,
        terminalFees Amount,
        requestUid string,
@@ -253,6 +255,7 @@ func (db *C2ECPostgres) SetupWithdrawal(
                terminalFees.Fraction,
                terminalFees.Currency,
                ts.Unix(),
+               terminalId,
        )
        if err != nil {
                LogError("postgres", err)
diff --git a/c2ec/db.go b/c2ec/db.go
index ee975e0..e10702a 100644
--- a/c2ec/db.go
+++ b/c2ec/db.go
@@ -112,6 +112,7 @@ type C2ECDatabase interface {
                wopid []byte,
                suggestedAmount Amount,
                amount Amount,
+               terminalId int,
                providerTransactionId string,
                terminalFees Amount,
                requestUid string,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]