feat: stream CreditCall payment progress and results
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package creditcall
|
||||
|
||||
import "gitea.futuresens.co.uk/futuresens/hardlink/paymentstatus"
|
||||
|
||||
// ProgressStatus maps informational SDK events, never financial decisions.
|
||||
func ProgressStatus(source, value string) string {
|
||||
switch source {
|
||||
case "UPDATE":
|
||||
switch value {
|
||||
case "CardRequested", "ProvideCard", "InsertOrSwipeCard", "InsertOrContactless":
|
||||
return paymentstatus.PresentCard
|
||||
case "InsertCard":
|
||||
return paymentstatus.InsertCard
|
||||
case "SwipeCard":
|
||||
return paymentstatus.SwipeCard
|
||||
case "CardRemovalRequested", "CardRemovalEnforced":
|
||||
return paymentstatus.RemoveCard
|
||||
case "PinEntryStarted", "PinEntryPrompt", "PinEntryInProgress":
|
||||
return paymentstatus.EnterPIN
|
||||
case "PinEntryFailed":
|
||||
return paymentstatus.EnterPINAgain
|
||||
case "PinEntrySuccessful", "TransactionStarted", "OnlineAuthRequested", "OnlineAuthorizeRequest":
|
||||
return paymentstatus.Processing
|
||||
case "OnlineAuthCompleted":
|
||||
return paymentstatus.PleaseWait
|
||||
}
|
||||
case "CARD_STATUS":
|
||||
switch value {
|
||||
case "Inserted":
|
||||
return paymentstatus.DoNotRemoveCard
|
||||
case "Tapped", "Swiped":
|
||||
return paymentstatus.Processing
|
||||
}
|
||||
case "SIGNATURE":
|
||||
if value == "Requested" {
|
||||
return paymentstatus.SignatureRequired
|
||||
}
|
||||
case "PAUSE":
|
||||
if value == "Paused" {
|
||||
return paymentstatus.PleaseWait
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// MaskedCardNumber excludes unmasked or unexpected SDK data from the new wire contract.
|
||||
func MaskedCardNumber(value string) string {
|
||||
digits, masks := 0, 0
|
||||
for _, ch := range value {
|
||||
switch {
|
||||
case ch >= '0' && ch <= '9':
|
||||
digits++
|
||||
case ch == '*' || ch == 'x' || ch == 'X':
|
||||
masks++
|
||||
case ch == ' ' || ch == '-':
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
if masks < 4 || digits > 10 {
|
||||
return ""
|
||||
}
|
||||
return value
|
||||
}
|
||||
Reference in New Issue
Block a user