Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
975707de4c |
@@ -69,7 +69,7 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func checkStatus(statusResp []byte) (string, error) {
|
func checkStatus(statusResp []byte) ([]string, error) {
|
||||||
if len(statusResp) > 3 {
|
if len(statusResp) > 3 {
|
||||||
statusBytes := statusResp[7:11] // Extract the relevant bytes from the response
|
statusBytes := statusResp[7:11] // Extract the relevant bytes from the response
|
||||||
// For each position, get the ASCII character, hex value, and mapped meaning.
|
// For each position, get the ASCII character, hex value, and mapped meaning.
|
||||||
@@ -84,17 +84,17 @@ func checkStatus(statusResp []byte) (string, error) {
|
|||||||
{pos: 4, value: statusBytes[3], mapper: statusPos3},
|
{pos: 4, value: statusBytes[3], mapper: statusPos3},
|
||||||
}
|
}
|
||||||
|
|
||||||
result := ""
|
result := make([]string, len(posStatus))
|
||||||
for _, p := range posStatus {
|
for _, p := range posStatus {
|
||||||
statusMsg, exists := p.mapper[p.value]
|
statusMsg, exists := p.mapper[p.value]
|
||||||
if !exists {
|
if !exists {
|
||||||
statusMsg = "Unknown status"
|
statusMsg = "Unknown status"
|
||||||
}
|
}
|
||||||
if p.value != 0x30 {
|
if p.value != 0x30 {
|
||||||
result += fmt.Sprintf("Status: %s; ", statusMsg)
|
result = append(result, fmt.Sprintf("Status: %s; ", statusMsg))
|
||||||
}
|
}
|
||||||
if p.pos == 4 && p.value == 0x38 {
|
if p.pos == 4 && p.value == 0x38 {
|
||||||
return result, fmt.Errorf("Card well empty")
|
return nil, fmt.Errorf("Card well empty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
+17
-2
@@ -271,7 +271,7 @@ func (app *App) issueDoorCard(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// dispenser sequence
|
// card to encoder position if not there already
|
||||||
if status, err := dispenser.DispenserSequence(app.dispPort); err != nil {
|
if status, err := dispenser.DispenserSequence(app.dispPort); err != nil {
|
||||||
if status != "" {
|
if status != "" {
|
||||||
logging.Error(serviceName, status, "Dispense error", string(op), "", "", 0)
|
logging.Error(serviceName, status, "Dispense error", string(op), "", "", 0)
|
||||||
@@ -294,10 +294,11 @@ func (app *App) issueDoorCard(w http.ResponseWriter, r *http.Request) {
|
|||||||
logging.Error(serviceName, err.Error(), "Key encoding", string(op), "", "", 0)
|
logging.Error(serviceName, err.Error(), "Key encoding", string(op), "", "", 0)
|
||||||
writeError(w, http.StatusBadGateway, err.Error())
|
writeError(w, http.StatusBadGateway, err.Error())
|
||||||
dispenser.CardOutOfMouth(app.dispPort)
|
dispenser.CardOutOfMouth(app.dispPort)
|
||||||
|
dispenser.DispenserSequence(app.dispPort)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// final dispenser steps
|
// card out of mouth
|
||||||
if status, err := dispenser.CardOutOfMouth(app.dispPort); err != nil {
|
if status, err := dispenser.CardOutOfMouth(app.dispPort); err != nil {
|
||||||
logging.Error(serviceName, err.Error(), "Dispenser eject error", string(op), "", "", 0)
|
logging.Error(serviceName, err.Error(), "Dispenser eject error", string(op), "", "", 0)
|
||||||
writeError(w, http.StatusServiceUnavailable, "Dispenser eject error: "+err.Error())
|
writeError(w, http.StatusServiceUnavailable, "Dispenser eject error: "+err.Error())
|
||||||
@@ -306,6 +307,20 @@ func (app *App) issueDoorCard(w http.ResponseWriter, r *http.Request) {
|
|||||||
log.Info(status)
|
log.Info(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// card to encoder position
|
||||||
|
if status, err := dispenser.DispenserSequence(app.dispPort); err != nil {
|
||||||
|
if status != "" {
|
||||||
|
logging.Error(serviceName, status, "Dispense error", string(op), "", "", 0)
|
||||||
|
writeError(w, http.StatusServiceUnavailable, "Dispense error: "+err.Error())
|
||||||
|
} else {
|
||||||
|
logging.Error(serviceName, err.Error(), "Dispense error", string(op), "", "", 0)
|
||||||
|
writeError(w, http.StatusServiceUnavailable, "Dispense error: "+err.Error()+"; check card stock")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
log.Info(status)
|
||||||
|
}
|
||||||
|
|
||||||
theResponse.Code = http.StatusOK
|
theResponse.Code = http.StatusOK
|
||||||
theResponse.Message = "Card issued successfully"
|
theResponse.Message = "Card issued successfully"
|
||||||
// success! return 200 and any data you like
|
// success! return 200 and any data you like
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
|
|
||||||
"gitea.futuresens.co.uk/futuresens/hardlink/bootstrap"
|
"gitea.futuresens.co.uk/futuresens/hardlink/bootstrap"
|
||||||
"gitea.futuresens.co.uk/futuresens/hardlink/config"
|
"gitea.futuresens.co.uk/futuresens/hardlink/config"
|
||||||
@@ -14,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
buildVersion = "1.0.2"
|
buildVersion = "1.0.0"
|
||||||
serviceName = "preauth-release"
|
serviceName = "preauth-release"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -33,17 +32,11 @@ func main() {
|
|||||||
defer database.Close()
|
defer database.Close()
|
||||||
|
|
||||||
if err := payment.ReleasePreauthorizations(database); err != nil {
|
if err := payment.ReleasePreauthorizations(database); err != nil {
|
||||||
log.Error(err)
|
log.WithError(err).Fatal("Preauth release failed")
|
||||||
fmt.Println(err)
|
|
||||||
} else {
|
|
||||||
log.Info("Task completed successfully")
|
|
||||||
fmt.Println("Task completed successfully")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 20; i > 0; i-- {
|
log.Info("Task completed successfully")
|
||||||
fmt.Printf("\rExiting in %2d seconds... ", i)
|
fmt.Println(". Press Enter to exit...")
|
||||||
time.Sleep(time.Second)
|
fmt.Scanln()
|
||||||
}
|
|
||||||
fmt.Println("\rExiting now. ")
|
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
buildVersion = "1.0.30"
|
buildVersion = "1.0.28"
|
||||||
serviceName = "hardlink"
|
serviceName = "hardlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -65,6 +65,9 @@ func main() {
|
|||||||
fmt.Println(err.Error())
|
fmt.Println(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if status, err = dispenser.DispenserSequence(dispHandle); err != nil {
|
||||||
|
handlers.FatalError(err)
|
||||||
|
}
|
||||||
log.Infof("Dispenser initialized on port %s, %s", config.DispenserPort, status)
|
log.Infof("Dispenser initialized on port %s, %s", config.DispenserPort, status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
/* ==============================
|
/* ==============================
|
||||||
Public Entry Point
|
Public Entry Point (LEGACY)
|
||||||
============================== */
|
============================== */
|
||||||
|
|
||||||
func ReleasePreauthorizations(database *sql.DB) error {
|
func ReleasePreauthorizations(database *sql.DB) error {
|
||||||
@@ -78,7 +78,6 @@ func handlePreauthRelease(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Infof("res=%s state=%s", info.transactionRes, info.transactionState)
|
|
||||||
|
|
||||||
// If already voided or declined → mark released
|
// If already voided or declined → mark released
|
||||||
if isAlreadyReleased(info) {
|
if isAlreadyReleased(info) {
|
||||||
@@ -87,7 +86,8 @@ func handlePreauthRelease(
|
|||||||
|
|
||||||
// Only void approved + uncommitted
|
// Only void approved + uncommitted
|
||||||
if !isVoidable(info) {
|
if !isVoidable(info) {
|
||||||
log.Infof("Preauth %s not eligible for void (res=%s state=%s)", ref, info.transactionRes, info.transactionState)
|
log.Infof("Preauth %s not eligible for void (res=%s state=%s)",
|
||||||
|
ref, info.transactionRes, info.transactionState)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,6 @@
|
|||||||
|
|
||||||
builtVersion is a const in main.go
|
builtVersion is a const in main.go
|
||||||
|
|
||||||
#### 1.0.30 - 09 January 2026
|
|
||||||
improved logging for preauth releaser
|
|
||||||
|
|
||||||
#### 1.0.29 - 08 January 2026
|
|
||||||
added count down before exiting the preauth releaser 20 seconds
|
|
||||||
|
|
||||||
#### 1.0.28 - 10 December 2025
|
#### 1.0.28 - 10 December 2025
|
||||||
added preauth releaser
|
added preauth releaser
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user