public static bool CheckForAbortApdu(CommandResult cmdResult, ApduCollection collection) { AbortApduResponse abort = collection.FindFirstApduOfType <AbortApduResponse>(); if (abort != null) { cmdResult.Success = false; cmdResult.ProtocolSpecificErrorCode = (byte)abort.ResultCode; cmdResult.ProtocolSpecificErrorDescription = abort.ResultCode.ToString(); return(true); } StatusApdu status = collection.FindFirstApduOfType <StatusApdu>(); if (status != null && status.Status != StatusCodes.ErrorIDEnum.NoError) { cmdResult.Success = false; cmdResult.ProtocolSpecificErrorCode = (byte)status.Status; cmdResult.ProtocolSpecificErrorDescription = status.Status.ToString(); return(true); } return(false); }
public PaymentResult Execute() { if (_environment.RaiseAskOpenConnection()) { _transport.OpenConnection(); } ApduCollection responses = _commandTransmitter.TransmitAPDU(_apdu); if (_environment.RaiseAskCloseConnection()) { _transport.CloseConnection(); } //Contains the result (success or failure) and much information about the transaction StatusInformationApdu statusInformation = responses.FindFirstApduOfType <StatusInformationApdu>(); //Completion is only sent if everything worked fine CompletionApduResponse completion = responses.FindFirstApduOfType <CompletionApduResponse>(); //Abort is only sent if something went wrong AbortApduResponse abort = responses.FindFirstApduOfType <AbortApduResponse>(); //If the terminal is not registered a application layer nack (0x84 XX XX) is sent StatusApdu status = responses.FindFirstApduOfType <StatusApdu>(); bool success = true; int? errorCode = null; string errorDescription = ""; if (completion == null && abort != null) { success = false; errorCode = (byte)abort.ResultCode; errorDescription = abort.ResultCode.ToString(); } else if (statusInformation != null) { StatusInformationResultCode result = statusInformation.FindParameter <StatusInformationResultCode>(StatusInformationApdu.StatusParameterEnum.ResultCode); if (result.ResultCode != StatusCodes.ErrorIDEnum.NoError) { success = false; errorCode = (byte)result.ResultCode; errorDescription = result.ResultCode.ToString(); } } else if (status != null && status.Status != StatusCodes.ErrorIDEnum.NoError) { success = false; errorCode = (byte)status.Status; errorDescription = status.Status.ToString(); } PaymentResult authResult = new PaymentResult(success, errorCode, errorDescription, statusInformation); authResult.PrintDocuments = _commandTransmitter.PrintDocuments; return(authResult); }