Challenge Status Receiver
ChallengeStatusReceiver is an interface used to obtain the result of the SDK challenge process. This should be implemented in the application and passed to the doChallenge method when Starting the Challenge. When the challenge process has finished, either successfully or in error, one of the following corresponding methods will be called:
Name | Description |
completed | Called when the challenge process (that is, the transaction) is completed. When a transaction is completed, a transaction status will be available. |
cancelled | Called when the cardholder selects the option to cancel the transaction on the challenge screen. |
timedout | Called when the challenge process reaches or exceeds the timeout interval that is specified during the doChallenge call. |
protocolError | Called when the 3DS SDK receives an EMV® 3-D Secure protocol-defined error message from the ACS. |
runtimeError | Called when the 3DS SDK encounters errors during the challenge process. These errors include all errors except those covered by the protocolError method. |
func completed(_ completionEvent: CompletionEvent) {
showToast("Challenge completed with transactionStatus " + completionEvent.getTransactionStatus())
try? closeTransaction()
}
func cancelled() {
showToast("Challenge cancelled.")
try? closeTransaction()
}
func timedout() {
showToast("Challenge timed out.")
try? closeTransaction()
}
func protocolError(_ protocolErrorEvent: ProtocolErrorEvent) {
showToast("Challenge protocolError: " +
protocolErrorEvent.getErrorMessage().getErrorDescription() + "\t" +
protocolErrorEvent.getErrorMessage().getErrorDetails());
try? closeTransaction()
}
func runtimeError(_ runtimeErrorEvent: RuntimeErrorEvent) {
showToast("Challenge runtimeError: " + runtimeErrorEvent.getErrorMessage());
try? closeTransaction()
}
// Helper method
func closeTransaction() throws {
if sdkTransaction != nil {
try sdkTransaction?.close()
sdkTransaction = nil
}
}