feat(hardlink): unify kiosk payments and finalize legacy cleanup
This commit is contained in:
@@ -16,12 +16,6 @@ import (
|
||||
|
||||
// XML parsing structs
|
||||
type (
|
||||
TransactionRec struct {
|
||||
XMLName xml.Name `xml:"TransactionPayload"`
|
||||
AmountMinorUnits string `xml:"amount"`
|
||||
TransactionType string `xml:"transactionType"`
|
||||
}
|
||||
|
||||
TransactionResultXML struct {
|
||||
XMLName xml.Name `xml:"TransactionResult"`
|
||||
Entries []EntryXML `xml:"Entry"`
|
||||
@@ -99,39 +93,6 @@ func (r *PaymentResult) FillFromTransactionResult(trResult TransactionResultXML)
|
||||
}
|
||||
}
|
||||
|
||||
// BuildPaymentRedirectURL builds the redirect URL to send the guest to after payment.
|
||||
func BuildPaymentRedirectURL(result map[string]string) string {
|
||||
res := result[types.TransactionResult]
|
||||
|
||||
// Transaction approved?
|
||||
if strings.EqualFold(res, types.ResultApproved) {
|
||||
// Transaction confirmed?
|
||||
if strings.EqualFold(result[types.ConfirmResult], types.ResultApproved) {
|
||||
log.WithField(types.LogResult, result[types.ConfirmResult]).
|
||||
Info("Transaction approved and confirmed")
|
||||
|
||||
return BuildSuccessURL(result)
|
||||
}
|
||||
|
||||
// Not confirmed
|
||||
log.WithFields(log.Fields{types.LogFieldError: result[types.ConfirmResult], types.LogFieldDescription: result[types.ConfirmErrors]}).
|
||||
Error("Transaction approved but not confirmed")
|
||||
|
||||
return BuildFailureURL(result[types.ConfirmResult], result[types.ConfirmErrors])
|
||||
}
|
||||
|
||||
// Not approved
|
||||
return BuildFailureURL(res, result[types.Errors])
|
||||
}
|
||||
|
||||
func BuildPreauthRedirectURL(result map[string]string) (string, bool) {
|
||||
approved, persist := PreauthDecision(result)
|
||||
if approved {
|
||||
return BuildSuccessURL(result), persist
|
||||
}
|
||||
return BuildFailureURL(result[types.TransactionResult], result[types.Errors]), false
|
||||
}
|
||||
|
||||
// PreauthDecision preserves the returned-type approval and persistence rules.
|
||||
func PreauthDecision(result map[string]string) (approved, persist bool) {
|
||||
res := result[types.TransactionResult]
|
||||
|
||||
Reference in New Issue
Block a user