Refactor PDQ lookup for payment providers
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"gitea.futuresens.co.uk/futuresens/hardlink/internal/errorhandlers"
|
||||
"github.com/alexbrainman/printer"
|
||||
log "github.com/sirupsen/logrus"
|
||||
imagedraw "golang.org/x/image/draw"
|
||||
@@ -94,7 +95,30 @@ func ParseCardholderReceipt(data []byte) ([]ReceiptEntryXML, error) {
|
||||
return tr.ReceiptEntries.ReceiptEntry, nil
|
||||
}
|
||||
|
||||
func readTicketLayout() LayoutOptions {
|
||||
var layout LayoutOptions
|
||||
|
||||
executablePath, err := os.Executable()
|
||||
if err != nil {
|
||||
errorhandlers.FatalError(fmt.Errorf("failed to locate application executable: %v", err))
|
||||
}
|
||||
|
||||
layoutName := filepath.Join(filepath.Dir(executablePath), "TicketLayout.xml")
|
||||
data, err := os.ReadFile(layoutName)
|
||||
if err != nil {
|
||||
errorhandlers.FatalError(fmt.Errorf("failed to read %s: %v", layoutName, err))
|
||||
}
|
||||
|
||||
if err := xml.Unmarshal(data, &layout); err != nil {
|
||||
errorhandlers.FatalError(fmt.Errorf("failed to parse %s: %v", layoutName, err))
|
||||
}
|
||||
|
||||
return layout
|
||||
}
|
||||
|
||||
func BuildRoomTicket(details RoomDetailsRec) ([]byte, error) {
|
||||
Layout = readTicketLayout()
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
||||
// shortcuts
|
||||
|
||||
Reference in New Issue
Block a user