public Transaction_Result Sale(Sale_Details details)
        {
            System.Collections.Specialized.NameValueCollection parameters = new System.Collections.Specialized.NameValueCollection();
            parameters.Add("auth_id", authID);
            parameters.Add("auth_pass", authPass);
            parameters.Add("card_num", details.CardNumber);
            parameters.Add("card_cvv", details.CardCCV);
            parameters.Add("card_expiry", GatewayUtils.formatExpiryDateYY(details.CardExpiryMonth, details.CardExpiryYear));
            parameters.Add("cust_name", details.CustomerFirstName);
            parameters.Add("cust_address", details.CustomerAddress);
            parameters.Add("cust_postcode", details.CustomerZip);
            parameters.Add("cust_country", details.CustomerCountryCodeTwoLetter);
            parameters.Add("cust_ip", details.IPAddress);
            parameters.Add("cust_email", details.CustomerEmail);
            parameters.Add("cust_tel", details.CustomerPhone);
            parameters.Add("tran_ref", details.ExtRef);
            parameters.Add("tran_amount", details.Amount.ToString("F2"));
            parameters.Add("tran_currency", details.CurrencyCode);
            parameters.Add("tran_testmode", Mode);
            parameters.Add("tran_type", "sale");
            parameters.Add("tran_class", "cont");

            var result = DoUrlEncodedFormPost("https://secure.cashflows.com/gateway/remote", parameters);

            var result_set = result.Split('|');

            if (result_set.Length != 5)
            {
                throw new Exception("Response format invalid");
            }

            var status = result_set[0];
            var transactionIdentifier = result_set[1];
            var avs       = result_set[2];
            var auth_code = result_set[3];
            var message   = result_set[4];

            bool isSuccess = status == "A";

            return(new Transaction_Result
            {
                ApprovalCode = isSuccess ? auth_code : "",
                ErrorCode = !isSuccess ? auth_code : "",
                ErrorText = !isSuccess ? message : "",
                FullRequest = KeyValueToQueryString(parameters),
                FullResponse = result,
                hasServerError = false,
                isApproved = isSuccess,
                isPending = false,
                ResultCode = avs,
                ResultText = message,
                TransactionIndex = transactionIdentifier
            });
        }
        public StorePaymentMethod_Result StorePaymentMethod(StorePaymentMethod_Details details)
        {
            System.Collections.Specialized.NameValueCollection parameters = new System.Collections.Specialized.NameValueCollection();
            parameters.Add("auth_id", authID);
            parameters.Add("auth_pass", authPass);
            parameters.Add("card_num", details.CardNumber);
            parameters.Add("card_cvv", details.CardCVV);
            parameters.Add("card_expiry", GatewayUtils.formatExpiryDateYY(details.CardExpiryMonth, details.CardExpiryYear));
            parameters.Add("cust_name", "");
            parameters.Add("cust_address", "");
            parameters.Add("cust_postcode", "");
            parameters.Add("cust_country", "");
            parameters.Add("cust_ip", "");
            parameters.Add("cust_email", "");
            parameters.Add("cust_tel", "");
            parameters.Add("tran_ref", details.ClientIdentifier);
            parameters.Add("tran_amount", "1.00");
            parameters.Add("tran_currency", "");
            parameters.Add("tran_testmode", Mode);
            parameters.Add("tran_type", "verify");
            parameters.Add("tran_class", "ecom");

            var result = DoUrlEncodedFormPost("https://secure.cashflows.com/gateway/remote", parameters);

            var result_set = result.Split('|');

            if (result_set.Length != 5)
            {
                throw new Exception("Response format invalid");
            }

            var status = result_set[0];
            var transactionIdentifier = result_set[1];
            var avs       = result_set[2];
            var auth_code = result_set[3];
            var message   = result_set[4];

            bool isSuccess = status == "A";

            return(new StorePaymentMethod_Result
            {
                CardToken = transactionIdentifier,
                ErrorCode = !isSuccess ? auth_code : "",
                ErrorMessage = !isSuccess ? message : "",
                isSuccess = isSuccess
            });
        }