commit 513fa3ee34e631fa1e483b0e76ec5df5b19f1bd5
parent 76ba50d709fbe5f8755d8e8dcaf28b562d8ccb6f
Author: Joel-Haeberli <haebu@rubigen.ch>
Date: Wed, 8 May 2024 15:19:00 +0200
fix: set terminal id
Diffstat:
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git 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
@@ -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
@@ -112,6 +112,7 @@ type C2ECDatabase interface {
wopid []byte,
suggestedAmount Amount,
amount Amount,
+ terminalId int,
providerTransactionId string,
terminalFees Amount,
requestUid string,