added route for taking preauthorization payment
This commit is contained in:
+28
-12
@@ -250,7 +250,31 @@ 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]
|
||||
|
||||
// Transaction approved?
|
||||
if strings.EqualFold(res, ResultApproved) {
|
||||
// Transaction confirmed?
|
||||
if strings.EqualFold(result[ConfirmResult], ResultApproved) {
|
||||
log.WithField(LogResult, result[ConfirmResult]).
|
||||
Info("Transaction approved and confirmed")
|
||||
|
||||
return buildSuccessURL(result)
|
||||
}
|
||||
|
||||
// Not confirmed
|
||||
log.WithFields(log.Fields{LogFieldError: result[ConfirmResult], LogFieldDescription: result[ConfirmErrors]}).
|
||||
Error("Transaction approved but not confirmed")
|
||||
|
||||
return BuildFailureURL(result[ConfirmResult], result[ConfirmErrors])
|
||||
}
|
||||
|
||||
// Not approved
|
||||
return BuildFailureURL(res, result[Errors])
|
||||
}
|
||||
|
||||
func BuildPreauthRedirectURL(result map[string]string) string {
|
||||
res := result[TransactionResult]
|
||||
tType := result[TransactionType]
|
||||
|
||||
@@ -267,18 +291,10 @@ func BuildRedirectURL(result map[string]string) string {
|
||||
// Transaction type Sale?
|
||||
case strings.EqualFold(tType, SaleTransactionType):
|
||||
// Transaction confirmed?
|
||||
if strings.EqualFold(result[ConfirmResult], ResultApproved) {
|
||||
log.WithField(LogResult, result[ConfirmResult]).
|
||||
Info("Transaction approved and confirmed")
|
||||
log.WithField(LogResult, result[ConfirmResult]).
|
||||
Info("Amount preauthorized successfully")
|
||||
|
||||
return buildSuccessURL(result)
|
||||
}
|
||||
|
||||
// Not confirmed
|
||||
log.WithFields(log.Fields{LogFieldError: result[ConfirmResult], LogFieldDescription: result[ConfirmErrors]}).
|
||||
Error("Transaction approved but not confirmed")
|
||||
|
||||
return BuildFailureURL(result[ConfirmResult], result[ConfirmErrors])
|
||||
return buildSuccessURL(result)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user