/// <summary> /// Verifies if the cancellation was declined or not. /// </summary> /// <param name="response">Cancellation response.</param> /// <returns>If the cancellation was declined or not.</returns> private bool WasDeclined(AcceptorCancellationResponse response) { if (response == null) { return(true); } return(response.Data.CancellationResponse.TransactionResponse.AuthorisationResult.ResponseToAuthorisation.Response != ResponseCode.Approved); }
/// <summary> /// Returns the declined message in case of a cancellation declined. /// </summary> /// <param name="response">Cancellation response.</param> /// <returns>Reason of decline.</returns> private string GetDeclinedMessage(AcceptorCancellationResponse response) { // Verifies if response is null. In this case, there's no declined message. if (response == null) { return(string.Empty); } // Gets the reason as a integer: int reasonCode = Int32.Parse(response.Data.CancellationResponse.TransactionResponse.AuthorisationResult.ResponseToAuthorisation.ResponseReason); // Verifies if the integer read from response XML exists in our response code enumerator: if (Enum.IsDefined(typeof(ResponseReasonCode), reasonCode) == true) { // Returns the corresponding declined message to the response code received: return(EnumDescriptionAttribute.GetDescription((ResponseReasonCode)reasonCode)); } else { // If the response is unknown, then shows it's integer code: return(string.Format("[Erro: {0}]", reasonCode)); } }