public UserModel GetCustomerDetailById(string storeId, object myVars, string userName, string userPwd, string dbType,
                            string uvAddress, string uvAccount, string cacheTIme, string dblCache,
                            string strd3PortNumber,
                            string useEncryption, string d3PortNumber)
        {
            var strPickDataReturn = DbAccess.GetStringResult(storeId, Constants.GetCustomerDetail, myVars, userName, userPwd,
                                                           dbType,
                                                           uvAddress, uvAccount, cacheTIme, dblCache, strd3PortNumber,
                                                           useEncryption, d3PortNumber);
            var objUserModel = new UserModel();

            //Read XML data
            var doc = new XmlDocument();

            doc.LoadXml(strPickDataReturn);

            var xmlResult = XElement.Parse(strPickDataReturn);

            if (xmlResult.Descendants("ERROR").Any())
            {
                //If not set error message
                objUserModel.ErrorMsg = xmlResult.Descendants("ERROR").SingleOrDefault().Value;
            }
            else
            {
                objUserModel = (from user in xmlResult.Descendants("LOGIN")
                                select new UserModel
                                {
                                    UserName = user.Element("LOGINID")!=null?user.Element("LOGINID").Value:"",
                                    FirstName =user.Element("FIRSTNAME")!=null?user.Element("FIRSTNAME").Value:"",
                                    LastName =user.Element("LASTNAME")!=null?user.Element("LASTNAME").Value:"",
                                    Address =user.Element("ADDRESS1")!=null?user.Element("ADDRESS1").Value:"",
                                    Address2 = user.Element("ADDRESS2")!=null?user.Element("ADDRESS2").Value:"",
                                    City =user.Element("CITY")!=null?user.Element("CITY").Value:"",
                                    State =user.Element("STATE")!=null?user.Element("STATE").Value:"",
                                    Zip =user.Element("ZIP")!=null?user.Element("ZIP").Value:"",
                                    Country = user.Element("COUNTRY")!=null?user.Element("COUNTRY").Value:"",
                                    DayPhone = user.Element("COUNTRY")!=null?user.Element("DAYPHONE").Value:"",
                                    Evening =user.Element("EVEPHONE")!=null? user.Element("EVEPHONE").Value:"",
                                    Email =user.Element("EMAIL")!=null?user.Element("EMAIL").Value:"",
                                    ShipToName =user.Element("SHIPTONAME")!=null?user.Element("SHIPTONAME").Value:"",
                                    ShipAddress = user.Element("SHIPTOADDRESS1")!=null?user.Element("SHIPTOADDRESS1").Value:"",
                                    ShipAddress2 =user.Element("SHIPTOADDRESS2")!=null?user.Element("SHIPTOADDRESS2").Value:"",
                                    ShipCity = user.Element("SHIPTOCITY")!=null?user.Element("SHIPTOCITY").Value:"",
                                    ShipState =user.Element("SHIPTOSTATE")!=null?user.Element("SHIPTOSTATE").Value:"",
                                    ShipZip =user.Element("SHIPTOZIP")!=null?user.Element("SHIPTOZIP").Value:"",
                                    ShipCountry =user.Element("SHIPTOCOUNTRY")!=null?user.Element("SHIPTOCOUNTRY").Value:"",
                                    ShipInstruc =user.Element("SHIPINSTRUCTIONS")!=null?user.Element("SHIPINSTRUCTIONS").Value:"",
                                    EmailOptIn =user.Element("OPTIN")!=null?user.Element("OPTIN").Value:"",
                                    Type =user.Element("TYPE")!=null?user.Element("TYPE").Value:"",
                                    TypeDescrition =user.Element("TYPEDESC")!=null?user.Element("TYPEDESC").Value:"",
                                    AllAccountType = (from ddlAccountType in xmlResult.Descendants("DDINFO") select ddlAccountType.Element("TEXT") != null ? ddlAccountType.Element("TEXT").Value : "")
                                }).SingleOrDefault();
            }

            return objUserModel;
        }
        // <summary>
        //      Function for performing and AVS check
        // </summary>
        // <returns>
        //      string
        // </returns>
        public string PerformAVSCheck(UserModel user, string token)
        {
            // Create Client and Response objects
            ExpressSoapClient express = new ExpressSoapClient();
            Response response = new Response();

            // Call Element AVS Setup classes/functions
            GetAVSConfig(user, token);
            ExtendedParameters[] arExt = GetExtendedParameters(token);

            System.Diagnostics.Debug.Write(token);

            // Generate response
            response = express.CreditCardAVSOnly(credentials, application, terminal, card, transaction, address, arExt);

            // Return response
            return response.Card.AVSResponseCode;
        }
        // <summary>
        //      Function for setting up an Element Transaction environment
        // </summary>
        // <returns>
        //      NameValueCollection
        // </returns>
        public ElementResponseModel SetupTransaction(UserModel user, string amount, string redirectUrl)
        {
            // Create Client and Response objects
            ExpressSoapClient express = new ExpressSoapClient();
            Response response = new Response();

            // Call Element Setup classes/functions
            GetSetupConfig(user, amount, redirectUrl);

            // Generate and interpret response
            response = express.TransactionSetup(credentials, application, terminal, transaction, transactionSetup, address, paymentAccount, null);
            string tsi = response.TransactionSetup.TransactionSetupID;
            string tempvalcode = response.TransactionSetup.ValidationCode;

            // Store response data
            responseCollection = new ElementResponseModel();
            responseCollection.TransactionSetupId = tsi.ToString();
            responseCollection.ValidationCode = tempvalcode.ToString();

            // Return store response data
            return responseCollection;
        }
        /// <summary>
        /// To check user is valid or not...
        /// </summary>
        /// <param name="storeId"></param>
        /// <param name="login"></param>
        /// <param name="password"></param>
        /// <param name="userName"></param>
        /// <param name="userPwd"></param>
        /// <param name="dbType"></param>
        /// <param name="uvAddress"></param>
        /// <param name="uvAccount"></param>
        /// <param name="cacheTIme"></param>
        /// <param name="dblCache"></param>
        /// <param name="strd3PortNumber"></param>
        /// <param name="useEncryption"></param>
        /// <param name="d3PortNumber"></param>
        /// <returns></returns>
        public UserModel ValidUser(string storeId, string login, string password, string userName, string userPwd,
                         string dbType, string uvAddress, string uvAccount, string cacheTIme, string dblCache,
                         string strd3PortNumber, string useEncryption, string d3PortNumber)
        {
            //Create UserModel object..
            var objUserModel = new UserModel();

            object myObject1 = new { LOGIN = login };

            var saltstring = AccountSettingsDao.SaltUser(storeId, myObject1, userName, userPwd, dbType,
                                                         uvAddress, uvAccount, cacheTIme,
                                                         dblCache, strd3PortNumber, useEncryption,
                                                         d3PortNumber);

            var md5Password = Constants.GetMd5Hash(saltstring + password);

            var myVars = new { LOGIN = login, MD5 = md5Password + ":" + saltstring, PASSWORD = password };

            //Get XML Result of valid user availablitiy
            objUserModel = AccountSettingsDao.ValidUser(storeId, myVars, userName,
                                                                 userPwd, dbType, uvAddress, uvAccount, cacheTIme,
                                                                 dblCache, strd3PortNumber, useEncryption, d3PortNumber);

            return objUserModel;
        }
        /// <summary>
        /// Update the user details..
        /// </summary>
        /// <param name="storeId"></param>
        /// <param name="login"></param>
        /// <param name="firstname"></param>
        /// <param name="lastname"></param>
        /// <param name="address"></param>
        /// <param name="address2"></param>
        /// <param name="city"></param>
        /// <param name="state"></param>
        /// <param name="zip"></param>
        /// <param name="country"></param>
        /// <param name="email"></param>
        /// <param name="dayphone"></param>
        /// <param name="evephone"></param>
        /// <param name="shiptoname"></param>
        /// <param name="shipaddress"></param>
        /// <param name="shipaddress2"></param>
        /// <param name="shipcity"></param>
        /// <param name="shipstate"></param>
        /// <param name="shipzip"></param>
        /// <param name="shipcountry"></param>
        /// <param name="shipinstruc"></param>
        ///  /// <param name="accountType"></param>
        /// <param name="emailoptin"></param>
        /// <param name="userName"></param>
        /// <param name="userPwd"></param>
        /// <param name="dbType"></param>
        /// <param name="uvAddress"></param>
        /// <param name="uvAccount"></param>
        /// <param name="cacheTIme"></param>
        /// <param name="dblCache"></param>
        /// <param name="strd3PortNumber"></param>
        /// <param name="useEncryption"></param>
        /// <param name="d3PortNumber"></param>
        /// <returns></returns>
        public UserModel UpdateUser(string storeId, string login, string firstname, string lastname, string address, string address2, string city,
           string state, string zip, string country, string email, string dayphone, string evephone, string shiptoname, string shipaddress, string shipaddress2,
           string shipcity, string shipstate, string shipzip, string shipcountry, string shipinstruc, string emailoptin, string accountType, string userName, string userPwd, string dbType, string uvAddress,
           string uvAccount, string cacheTIme, string dblCache, string strd3PortNumber, string useEncryption, string d3PortNumber)
        {
            //Create UserModel object..
            var objUserModel = new UserModel();

            try
            {
                //Set User Properties..
                var myObject = new
                {
                    FIRSTNAME = firstname,
                    LASTNAME = lastname,
                    ADDRESS1 = address,
                    ADDRESS2 = !string.IsNullOrEmpty(address2) ? address2 : string.Empty,
                    CITY = city,
                    STATE = state,
                    ZIP = zip,
                    COUNTRY = country,
                    EMAIL = email,
                    DAYPHONE = dayphone,
                    EVEPHONE = evephone,
                    LOGIN = login,
                    SHIPTONAME = shiptoname,
                    SHIPTOADDRESS1 = shipaddress,
                    SHIPTOADDRESS2 = !string.IsNullOrEmpty(shipaddress2) ? shipaddress2 : string.Empty,
                    SHIPTOCITY = shipcity,
                    SHIPTOSTATE = shipstate,
                    SHIPTOZIP = shipzip,
                    SHIPTOCOUNTRY = shipcountry,
                    SHIPINSTRUCTIONS = !string.IsNullOrEmpty(shipinstruc) ? shipinstruc : string.Empty,
                    EMAILOPTIN = "Y",
                    ACCTYPE = accountType
                };

                //Update user...
                objUserModel = AccountSettingsDao.UpdateUser(storeId, myObject, userName, userPwd,
                                                             dbType, uvAddress, uvAccount, cacheTIme, dblCache,
                                                             strd3PortNumber, useEncryption, d3PortNumber);
            }
            catch (Exception ex)
            {
                objUserModel.ErrorMsg = ex.Message;
            }

            return objUserModel;
        }
        /// <summary>
        /// Add User in database : Implementation 
        /// </summary>
        /// <param name="storeId"></param>
        /// <param name="login"></param>
        /// <param name="password"></param>
        /// <param name="firstname"></param>
        /// <param name="lastname"></param>
        /// <param name="address"></param>
        /// <param name="address2"></param>
        /// <param name="city"></param>
        /// <param name="state"></param>
        /// <param name="zip"></param>
        /// <param name="country"></param>
        /// <param name="email"></param>
        /// <param name="dayphone"></param>
        /// <param name="evephone"></param>
        /// <param name="shiptoname"></param>
        /// <param name="shipaddress"></param>
        /// <param name="shipaddress2"></param>
        /// <param name="shipcity"></param>
        /// <param name="shipstate"></param>
        /// <param name="shipzip"></param>
        /// <param name="shipcountry"></param>
        /// <param name="shipinstruc"></param>
        /// <param name="emailoptin"> </param>
        /// <param name="userName"></param>
        /// <param name="userPwd"></param>
        /// <param name="dbType"></param>
        /// <param name="uvAddress"></param>
        /// <param name="uvAccount"></param>
        /// <param name="cacheTIme"></param>
        /// <param name="dblCache"></param>
        /// <param name="strd3PortNumber"></param>
        /// <param name="useEncryption"></param>
        /// <param name="d3PortNumber"></param>
        /// <returns></returns>
        public UserModel AddUser(string storeId, string login, string password, string firstname, string lastname, string address, string address2, string city,
            string state, string zip, string country, string email, string dayphone, string evephone, string shiptoname, string shipaddress, string shipaddress2,
            string shipcity, string shipstate, string shipzip, string shipcountry, string shipinstruc, string emailoptin, string userName, string userPwd, string dbType, string uvAddress,
            string uvAccount, string cacheTIme, string dblCache, string strd3PortNumber, string useEncryption, string d3PortNumber)
        {
            //Create UserModel object..
            var objUserModel = new UserModel();

            try
            {
                //Check user name is available to create new user..

                //Get XML Result of Check user availablitiy
                var isUserNameAvailable = CheckUser(storeId, login, userName,
                                                    userPwd, dbType, uvAddress, uvAccount, cacheTIme,
                                                    dblCache, strd3PortNumber, useEncryption, d3PortNumber);
                if (!isUserNameAvailable)
                {
                    objUserModel.ErrorMsg = "That username is taken";
                }
                else
                {
                    //if yes then add new user with given username and password..
                    var myObject2 = new
                    {
                        LOGIN = login,
                        PASSWORD = password
                    };

                    //Get User Model
                    objUserModel = AccountSettingsDao.AddUser(storeId, myObject2, userName, userPwd,
                                                              dbType, uvAddress, uvAccount, cacheTIme, dblCache,
                                                              strd3PortNumber, useEncryption, d3PortNumber);

                    //Check if any error
                    if (string.IsNullOrEmpty(objUserModel.ErrorMsg))
                    {
                        //If not then update other details..
                        var myObject3 = new
                        {
                            FIRSTNAME = firstname,
                            LASTNAME = lastname,
                            ADDRESS1 = address,
                            ADDRESS2 = !string.IsNullOrEmpty(address2) ? address2 : string.Empty,
                            CITY = city,
                            STATE = state,
                            ZIP = zip,
                            COUNTRY = country,
                            EMAIL = email,
                            DAYPHONE = dayphone,
                            EVEPHONE = evephone,
                            LOGIN = login,
                            SHIPTONAME = shiptoname,
                            SHIPTOADDRESS1 = shipaddress,
                            SHIPTOADDRESS2 = !string.IsNullOrEmpty(shipaddress2) ? shipaddress2 : string.Empty,
                            SHIPTOCITY = shipcity,
                            SHIPTOSTATE = shipstate,
                            SHIPTOZIP = shipzip,
                            SHIPTOCOUNTRY = shipcountry,
                            SHIPINSTRUCTIONS = !string.IsNullOrEmpty(shipinstruc) ? shipinstruc : string.Empty,
                            EMAILOPTIN = "Y"
                        };

                        //Update user...
                        objUserModel = AccountSettingsDao.UpdateUser(storeId, myObject3, userName, userPwd,
                                                                       dbType, uvAddress, uvAccount, cacheTIme, dblCache,
                                                                       strd3PortNumber, useEncryption, d3PortNumber);

                    }
                }

            }
            catch (Exception ex)
            {
                objUserModel.ErrorMsg = ex.Message;
            }

            return objUserModel;
        }
 private void GetSetupConfig(UserModel user, string amount, string redirectUrl)
 {
     GetApplication();
     GetCredentials();
     GetCard();
     GetTransactionTerminal();
     GetTransaction(amount);
     GetAddress(user);
     GetTransactionSetup(redirectUrl);
     GetPaymentAccount(user);
 }
        private void GetPaymentAccount(UserModel user)
        {
            paymentAccount = new PaymentAccount();

            // ##### TODO: Please change this to an actual account reference number attributed to the user #####
            string referenceId = GetSha1Hash(user.UserName + "{" + user.Email + "}");
            paymentAccount.PaymentAccountReferenceNumber = referenceId;
        }
 private void GetAVSConfig(UserModel user, string token)
 {
     GetApplication();
     GetCredentials();
     GetCard();
     GetAVSTerminal();
     GetTransaction("0.00");
     GetAddress(user);
     GetPaymentAccount(user);
 }
Example #10
0
        private void GetAddress(UserModel user)
        {
            address = new Address();

            address.BillingName = user.FirstName + " " + user.LastName;
            address.BillingAddress1 = user.Address;
            address.BillingAddress2 = user.Address2;
            address.BillingCity = user.City;
            address.BillingState = user.State;
            address.BillingZipcode = user.Zip;
            address.BillingPhone = user.DayPhone;
            address.BillingEmail = user.Email;
        }