public CancelAuthorisationResponse CancelAuthorisation(CancelAuthorisationRequest cancelRequest) { var request = _mappingService.Map <CancelAuthorisationRequest, DirectCancelAuthorisationRequest>(cancelRequest); var response = _rapidService.CancelAuthorisation(request); return(_mappingService.Map <DirectCancelAuthorisationResponse, CancelAuthorisationResponse>(response)); }
public override string VoidOrder(int orderNumber) { try { using (var connection = DB.dbConn()) { connection.Open(); DB.ExecuteSQL("update orders set voidtxcommand = null, voidtxresult = null where ordernumber = @orderNumber", connection, new SqlParameter("@orderNumber", orderNumber)); var authorizationPnref = DB.GetSqlS("select authorizationpnref S from orders with (nolock) where ordernumber = @orderNumber", new SqlParameter("@orderNumber", orderNumber)); var cancel = new CancelAuthorisationRequest() { TransactionId = authorizationPnref }; DB.ExecuteSQL("update orders set voidtxcommand = @voidTxCommand where ordernumber = @orderNumber", connection, new SqlParameter("@voidTxCommand", XmlCommon.SerializeObject(cancel, cancel.GetType())), new SqlParameter("@orderNumber", orderNumber)); var response = GetRapidClient() .CancelAuthorisation(cancel); if (!response.TransactionStatus) { var errorCode = string.IsNullOrWhiteSpace(response.ResponseMessage) && response.Errors != null ? string.Join(" ", response.Errors) : response.ResponseMessage; return($"There was a problem voiding the credit card transaction. Error code: {errorCode}."); } DB.ExecuteSQL("update orders set voidtxresult = @voidTxResult where ordernumber = @orderNumber", connection, new SqlParameter("@voidTxResult", XmlCommon.SerializeObject(response, response.GetType())), new SqlParameter("@orderNumber", orderNumber)); } } catch (Exception exception) { SysLog.LogException(exception, MessageTypeEnum.GeneralException, MessageSeverityEnum.Error); return("Error calling payment gateway."); } return(AppLogic.ro_OK); }
public void PreAuth_CancelAuthorisation_ReturnValidData() { var client = CreateRapidApiClient(); //Arrange var transaction = TestUtil.CreateTransaction(false); var preAuthTransaction = client.Create(PaymentMethod.Direct, transaction); //Act var preAuthRequest = new CancelAuthorisationRequest() { TransactionId = preAuthTransaction.TransactionStatus.TransactionID.ToString() }; var preAuthResponse = client.CancelAuthorisation(preAuthRequest); //Assert Assert.IsNotNull(preAuthResponse); Assert.IsTrue(preAuthResponse.TransactionStatus); Assert.IsNotNull(preAuthResponse.ResponseMessage); Assert.IsNotNull(preAuthResponse.ResponseCode); Assert.IsNotNull(preAuthResponse.TransactionID); }