fix(creditcall): require fresh confirmation approval for sale
This commit is contained in:
@@ -90,8 +90,8 @@ func (app *App) executeCreditCallSale(
|
||||
return outcome
|
||||
}
|
||||
|
||||
// Intentionally reuse both records: XML appends confirmation entries, and
|
||||
// missing confirmation fields/receipts retain their existing legacy behavior.
|
||||
// Reuse both records to preserve metadata and receipt merging. Only fresh
|
||||
// confirmation entries can establish completion approval.
|
||||
initialEntryCount := len(trResult.Entries)
|
||||
parseErr := trResult.ParseTransactionResult(body)
|
||||
if parseErr != nil {
|
||||
@@ -99,7 +99,21 @@ func (app *App) executeCreditCallSale(
|
||||
}
|
||||
result.FillFromTransactionResult(trResult)
|
||||
res = result.Fields[types.TransactionResult]
|
||||
if !strings.EqualFold(res, types.ResultApproved) {
|
||||
confirmationEntries := trResult.Entries[initialEntryCount:]
|
||||
var confirmationResult string
|
||||
for _, entry := range confirmationEntries {
|
||||
if entry.Key == types.TransactionResult {
|
||||
confirmationResult = entry.Value
|
||||
}
|
||||
}
|
||||
confirmationApproved := false
|
||||
if parseErr == nil {
|
||||
confirmationApproved = strings.EqualFold(confirmationResult, types.ResultApproved)
|
||||
}
|
||||
if !confirmationApproved {
|
||||
if strings.EqualFold(res, types.ResultApproved) {
|
||||
res = "unknown"
|
||||
}
|
||||
app.printCreditCallReceipt(result.CardholderReceipt)
|
||||
desc := result.Fields[types.ErrorDescription]
|
||||
if desc == "" {
|
||||
@@ -109,10 +123,11 @@ func (app *App) executeCreditCallSale(
|
||||
mail.SendEmailOnError(app.cfg.Hotel, app.cfg.Kiosk, "Payment confirmation failed", "Reference: "+ref+", Confirm result: "+res+" Description: "+desc)
|
||||
outcome.HTTPStatus = http.StatusOK
|
||||
outcome.Status = result.Status
|
||||
outcome.Status.Message = res
|
||||
outcome.Payment = result
|
||||
outcome.FailureType = res
|
||||
outcome.FailureDescription = result.Fields[types.Errors]
|
||||
outcome.confirmationDiagnostic = creditCallConfirmationResultDiagnostic(trResult.Entries[initialEntryCount:], parseErr != nil)
|
||||
outcome.confirmationDiagnostic = creditCallConfirmationResultDiagnostic(confirmationEntries, parseErr != nil)
|
||||
return outcome
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user