start of preauth

This commit is contained in:
2025-12-02 17:03:30 +00:00
parent bb526a248d
commit 56d33b167a
2 changed files with 130 additions and 2 deletions
+29 -1
View File
@@ -248,7 +248,7 @@ func nullableFloatArg(nf sql.NullFloat64) interface{} {
}
// BuildRedirectURL builds the redirect URL to send the guest to after payment.
func BuildRedirectURL(result map[string]string) string {
func BuildPaymentRedirectURL(result map[string]string) string {
res := result[TransactionResult]
tType := result[TransactionType]
@@ -284,6 +284,34 @@ func BuildRedirectURL(result map[string]string) string {
return BuildFailureURL(res, result[Errors])
}
func BuildPreauthRedirectURL(result map[string]string) string {
res := result[TransactionResult]
tType := result[TransactionType]
// Transaction approved?
if strings.EqualFold(res, ResultApproved) {
switch {
// Transaction type AccountVerification?
case strings.EqualFold(tType, AccountVerificationType):
log.WithField(LogResult, result[TransactionResult]).
Info("Account verification approved")
return buildSuccessURL(result)
// Transaction type Sale?
case strings.EqualFold(tType, SaleTransactionType):
// Transaction confirmed?
log.WithField(LogResult, result[ConfirmResult]).
Info("Transaction approved and confirmed")
return buildSuccessURL(result)
}
}
// Not approved
return BuildFailureURL(res, result[Errors])
}
func buildSuccessURL(result map[string]string) string {
q := url.Values{}
q.Set("TxnReference", result[Reference])