Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc91a9ae63 | ||
|
|
b303481b5f | ||
|
|
41cf71a253 |
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
// "database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -65,15 +65,13 @@ type App struct {
|
|||||||
dispPort *serial.Port
|
dispPort *serial.Port
|
||||||
lockConn net.Conn
|
lockConn net.Conn
|
||||||
lockserver lockserver.LockServer
|
lockserver lockserver.LockServer
|
||||||
db *sql.DB
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newApp(dispPort *serial.Port, lockConn net.Conn, config configRec, db *sql.DB) *App {
|
func newApp(dispPort *serial.Port, lockConn net.Conn, config configRec) *App {
|
||||||
return &App{
|
return &App{
|
||||||
dispPort: dispPort,
|
dispPort: dispPort,
|
||||||
lockConn: lockConn,
|
lockConn: lockConn,
|
||||||
lockserver: lockserver.NewLockServer(config.LockType, config.EncoderAddress, fatalError),
|
lockserver: lockserver.NewLockServer(config.LockType, config.EncoderAddress, fatalError),
|
||||||
db: db,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,11 +118,11 @@ func main() {
|
|||||||
defer lockConn.Close()
|
defer lockConn.Close()
|
||||||
log.Infof("Connected to lock server at %s", config.LockserverUrl)
|
log.Infof("Connected to lock server at %s", config.LockserverUrl)
|
||||||
|
|
||||||
db, err := payment.InitMSSQL(config.dbport, config.dbname, config.dbuser, config.dbpassword)
|
// db, err := payment.InitMSSQL(config.dbport, config.dbname, config.dbuser, config.dbpassword)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
fatalError(fmt.Errorf("DB init failed: %v", err))
|
// fatalError(fmt.Errorf("DB init failed: %v", err))
|
||||||
}
|
// }
|
||||||
defer db.Close()
|
// defer db.Close()
|
||||||
|
|
||||||
startClient := func() (*exec.Cmd, error) {
|
startClient := func() (*exec.Cmd, error) {
|
||||||
cmd := exec.Command("./ChipDNAClient/ChipDnaClient.exe")
|
cmd := exec.Command("./ChipDNAClient/ChipDnaClient.exe")
|
||||||
@@ -182,7 +180,7 @@ func main() {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// Create App and wire routes
|
// Create App and wire routes
|
||||||
app := newApp(dispHandle, lockConn, config, db)
|
app := newApp(dispHandle, lockConn, config)
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
setUpRoutes(app, mux)
|
setUpRoutes(app, mux)
|
||||||
@@ -310,9 +308,9 @@ func (app *App) startTransaction(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Insert into DB
|
// Insert into DB
|
||||||
if err := payment.InsertTransactionRecord(r.Context(), app.db, result); err != nil {
|
// if err := payment.InsertTransactionRecord(r.Context(), app.db, result); err != nil {
|
||||||
log.Errorf("DB insert error: %v", err)
|
// log.Errorf("DB insert error: %v", err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
theResponse.Data = payment.BuildRedirectURL(result)
|
theResponse.Data = payment.BuildRedirectURL(result)
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package payment
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"encoding/hex"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -261,8 +262,8 @@ func BuildRedirectURL(result map[string]string) string {
|
|||||||
// 3) build query params
|
// 3) build query params
|
||||||
q := url.Values{}
|
q := url.Values{}
|
||||||
q.Set("TxnReference", result["REFERENCE"])
|
q.Set("TxnReference", result["REFERENCE"])
|
||||||
q.Set("CardHash", result["CARD_HASH"])
|
q.Set("CardHash", hex.EncodeToString([]byte(result["CARD_HASH"])))
|
||||||
q.Set("CardReference", result["CARD_REFERENCE"])
|
q.Set("CardReference", hex.EncodeToString([]byte(result["CARD_REFERENCE"])))
|
||||||
|
|
||||||
// only append these when non-approved
|
// only append these when non-approved
|
||||||
if msgType != "" {
|
if msgType != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user