/// <summary>
        /// Void an order
        /// </summary>
        /// <param name="orderGuid">Order guid</param>
        /// <returns></returns>
        public VoidTransactionResult VoidTransaction(String orderGuid)
        {
            var result = new VoidTransactionResult();

            var transx = _sagePayServerTransactionService.GetSagePayServerTransactionByVendorTxCode(orderGuid);

            if (transx == null)
            {
                result.Message = String.Format("SagePay Server vendor transaction code {0} does not exist.", orderGuid);
                return(result);
            }


            var webClient = new WebClient();
            var voidGuid  = Guid.NewGuid();

            var data = new QueryStringNameValueCollection
            {
                { "VPSProtocol", SagePayHelper.GetProtocol() },
                { "TxType", "VOID" },
                { "Vendor", _sagePayServerPaymentSettings.VendorName },
                { "VendorTxCode", voidGuid.ToString() },
                { "VPSTxId", transx.VpsTxId },
                { "SecurityKey", transx.SecurityKey },
                { "TxAuthNo", transx.TxAuthNo },
            };

            var postUrl = SagePayHelper.GetSageSystemUrl(_sagePayServerPaymentSettings.ConnectTo, "void");

            string strResponse;

            try
            {
                var responseData = webClient.UploadValues(postUrl, data);

                strResponse = Encoding.ASCII.GetString(responseData);
            }
            catch (WebException ex)
            {
                result.Message = (String.Format(
                                      @"Your server was unable to release this transaction with Sage Pay.
                    Check that you do not have a firewall restricting the POST and 
                    that your server can correctly resolve the address {0}. <br/>
                    The Status Number is: {1}<br/>
                    The Description given is: {2}", postUrl, ex.Status, ex.Message));
                return(result);
            }

            if (string.IsNullOrWhiteSpace(strResponse))
            {
                result.Message = (String.Format(
                                      @"Your server was unable to register this transaction with Sage Pay.
                    Check that you do not have a firewall restricting the POST and 
                    that your server can correctly resolve the address {0}.", postUrl));
                return(result);
            }
            var strStatus       = SagePayHelper.FindField("Status", strResponse);
            var strStatusDetail = SagePayHelper.FindField("StatusDetail", strResponse);

            switch (strStatus)
            {
            case "OK":

                result.Success = true;
                break;

            case "MALFORMED":
                result.Message = (string.Format("Error ({0}: {1}) <br/> {2}", strStatus, strStatusDetail, data.Encode()));
                break;

            case "INVALID":
                result.Message = (string.Format("Error ({0}: {1}) <br/> {2}", strStatus, strStatusDetail, data.Encode()));
                break;

            default:
                result.Message = (string.Format("Error ({0}: {1})", strStatus, strStatusDetail));
                break;
            }

            return(result);
        }
        /// <summary>
        /// Void an order
        /// </summary>
        /// <param name="orderGuid">Order guid</param>
        /// <returns></returns>
        public VoidTransactionResult VoidTransaction(String orderGuid)
        {
            var result = new VoidTransactionResult();

            var transx = _sagePayServerTransactionService.GetSagePayServerTransactionByVendorTxCode(orderGuid);

            if (transx == null)
            {
                result.Message = String.Format("SagePay Server vendor transaction code {0} does not exist.", orderGuid);
                return result;
            }

            var webClient = new WebClient();
            var voidGuid = Guid.NewGuid();

            var data = new QueryStringNameValueCollection
                           {
                               {"VPSProtocol", SagePayHelper.GetProtocol()},
                               {"TxType", "VOID"},
                               {"Vendor", _sagePayServerPaymentSettings.VendorName},
                               {"VendorTxCode", voidGuid.ToString()},
                               {"VPSTxId", transx.VpsTxId},
                               {"SecurityKey", transx.SecurityKey},
                               {"TxAuthNo", transx.TxAuthNo},
                           };

            var postUrl = SagePayHelper.GetSageSystemUrl(_sagePayServerPaymentSettings.ConnectTo, "void");

            string strResponse;

            try
            {

                var responseData = webClient.UploadValues(postUrl, data);

                strResponse = Encoding.ASCII.GetString(responseData);

            }
            catch (WebException ex)
            {
                result.Message = (String.Format(
                    @"Your server was unable to release this transaction with Sage Pay.
                    Check that you do not have a firewall restricting the POST and
                    that your server can correctly resolve the address {0}. <br/>
                    The Status Number is: {1}<br/>
                    The Description given is: {2}", postUrl, ex.Status, ex.Message));
                return result;
            }

            if (string.IsNullOrWhiteSpace(strResponse))
            {
                result.Message = (String.Format(
                    @"Your server was unable to register this transaction with Sage Pay.
                    Check that you do not have a firewall restricting the POST and
                    that your server can correctly resolve the address {0}.", postUrl));
                return result;
            }
            var strStatus = SagePayHelper.FindField("Status", strResponse);
            var strStatusDetail = SagePayHelper.FindField("StatusDetail", strResponse);

            switch (strStatus)
            {
                case "OK":

                    result.Success = true;
                    break;

                case "MALFORMED":
                    result.Message = (string.Format("Error ({0}: {1}) <br/> {2}", strStatus, strStatusDetail, data.Encode()));
                    break;

                case "INVALID":
                    result.Message = (string.Format("Error ({0}: {1}) <br/> {2}", strStatus, strStatusDetail, data.Encode()));
                    break;

                default:
                    result.Message = (string.Format("Error ({0}: {1})", strStatus, strStatusDetail));
                    break;

            }

            return result;
        }