/// <summary> /// Voids the order. /// </summary> /// <param name="orderNumber">The Order Number.</param> /// <returns>Status of the transaction</returns> public override String VoidOrder(int orderNumber) { // merchant account string token = AppLogic.AppConfig("NETAXEPT.Merchant_Token"); string merchantID = AppLogic.AppConfig("NETAXEPT.Merchant_Id"); string responseText = string.Empty; string responseCode = string.Empty; string transactionString = Customer.Current.ThisCustomerSession["Nextaxept_TransactionString"]; string transID = String.Empty; string transactionState = string.Empty; decimal orderTotal = 0; using (SqlConnection conn = DB.dbConn()) { conn.Open(); using (IDataReader rs = DB.GetRS("SELECT AuthorizationPNREF, TransactionState, TransactionCommand, OrderTotal FROM Orders with (NOLOCK) where OrderNumber=" + orderNumber.ToString(), conn)) { if (rs.Read()) { orderTotal = DB.RSFieldInt(rs, "OrderTotal"); transactionState = DB.RSField(rs, "TransactionState"); transID = DB.RSField(rs, "AuthorizationPNREF"); transactionString = DB.RSField(rs, "TransactionCommand"); } } } // Only orders that is not captured can be void if (transactionState.Equals("CAPTURED", StringComparison.OrdinalIgnoreCase)) { return(AppLogic.GetString("Netaxept.VoidedCaptureError", Customer.Current.SkinID, Customer.Current.LocaleSetting)); } TokenService service = new TokenService(); // the server url string url = string.Empty; if (AppLogic.AppConfigBool("UseLiveTransactions")) { url = AppLogic.AppConfig("NETAXEPT.Live_Server"); // use live } else { url = AppLogic.AppConfig("NETAXEPT.Test_Server"); // use test } service.Url = url; try { Result result = null; Result authResult = null; result = service.ProcessSetup(token, merchantID, transactionString); authResult = service.Annul(token, merchantID, transID, string.Empty, string.Empty); DB.ExecuteSQL(string.Format("UPDATE Orders set VoidTXResult='{0}' where OrderNumber=" + orderNumber.ToString(), authResult.ResponseCode)); } catch (Exception ex) { SoapException se = ex as SoapException; if (se != null) { GetStatusCodeMessage(se, out responseText, out responseCode); DB.ExecuteSQL(string.Format("UPDATE Orders set VoidTXResult='{0}' WHERE OrderNumber=" + orderNumber.ToString(), responseCode)); if (!string.IsNullOrEmpty(responseText)) { return(responseText); } } return(ex.Message); } return(AppLogic.ro_OK); }