public static CardPaymentDTO MapToDTO(CardPaymentDAO cardPayment)
        {
            var cp = new CardPaymentDTO();

            cp.Id             = cardPayment.Id;
            cp.Customer       = CustomerMapper.MapToDTO(cardPayment.Customer);
            cp.CardNumber     = cardPayment.CardNumber;
            cp.CardHolderName = cardPayment.CardHolderName;
            cp.ExpirationDate = cardPayment.ExpirationDate;
            cp.CVC            = cardPayment.CVC;
            cp.Active         = cardPayment.Active;

            return(cp);
        }
Пример #2
0
        public IHttpActionResult RegisterForm(RegisterFormDTO registerForm)
        {
            PaymentItems    MyPaymentItems      = null;
            int             NoOfUsers           = 0;
            int             PurchaseItemsId     = 0;
            ResultReponse   MyResultResponse    = new ResultReponse();
            UserDTO         UserDTOInfo         = new UserDTO();
            SetupProcessDTO SetupProcessDTOInfo = new SetupProcessDTO();

            CardPaymentDTO  CardPaymentDTOInfo = null;
            SubscriptionDTO m_subscriptionDTO;
            //string APIKey = "sk_test_MCGUn4fT1YzFQzGcRa9HiC3v";

            string APIKey = "sk_test_ffjSM0I2xFEg7I18xCdxb9EJ";

            RegisterFormResults MyRegisterFormResults = new RegisterFormResults();
            string MessageBody      = "Welcome to MyUEL..";
            string TemplateBody     = "";
            string Subject          = "Message";
            string SubscriptionName = "";

            string        ExpMonth        = "";
            string        ExpYear         = "";
            ResultReponse MyResultReponse = new ResultReponse();

            try
            {
                //Get Stripe API Key
                //APIKey = "sk_test_ffjSM0I2xFEg7I18xCdxb9EJ";
                //m_subscriptionDTO = m_IRegisterBusiness.GetSubscriptionId(registerForm.Subscriptionid);

                //if (m_subscriptionDTO != null)
                //{
                //    NoOfUsers = m_subscriptionDTO.noOfUser;



                //    MyUELHelpers.Info(typeof(RegisterController).ToString(), "SaveUserDetails", "Started " + DateTime.Now.ToString());
                //    UserDTOInfo = m_IRegisterBusiness.creatingUsers(registerForm.FirstName, registerForm.LastName, registerForm.UserEmail,
                //        registerForm.Password, registerForm.Company, registerForm.Subscriptionid, m_subscriptionDTO);
                //    MyUELHelpers.Info(typeof(RegisterController).ToString(), "SaveUserDetails", "Done " + DateTime.Now.ToString());

                //    SubscriptionName = string.Format("{0}  {1}   {2} ", m_subscriptionDTO.SubscriptionName, m_subscriptionDTO.SubscriptionDays, m_subscriptionDTO.SubscriptionType);

                //    if (UserDTOInfo != null)
                //    {
                //        MyUserInfo.TenantId = UserDTOInfo.TenantId;
                //        MyUserInfo.UserId = UserDTOInfo.Id;
                //        MyUserInfo.UserName = UserDTOInfo.UserName;
                //        MyUserInfo.SubscriptionId = registerForm.Subscriptionid;
                //        MyUserInfo.SubscriptionName = m_subscriptionDTO.SubscriptionName;
                //        MyUserInfo.SubscriptionType = m_subscriptionDTO.SubscriptionType;
                //        MyRegisterFormResults.StatusCode = "USERREGISTER";
                //        MyRegisterFormResults.Status = "User Registration Done";
                //        MyRegisterFormResults.Message = "User Registration Done";
                //        MyUELHelpers.Info(typeof(RegisterController).ToString(), "Creating Table", "Started " + DateTime.Now.ToString());
                //        SetupProcessDTOInfo = m_ISetupProcessBusiness.CreateTable("boundhound" + MyUserInfo.TenantId, MyUserInfo);
                //        if (SetupProcessDTOInfo.Status == "SUCCESS")
                //        {
                //            MyUELHelpers.Info(typeof(RegisterController).ToString(), "Table Created Successfully", "End " + DateTime.Now.ToString());
                //            MyUserInfo.databasename = "MyUELLoyalty" + MyUserInfo.TenantId;
                //        }
                //        else
                //        {
                //            MyUELHelpers.Info(typeof(RegisterController).ToString(), "Creating Table Error", string.Format("Error {0}\n ", SetupProcessDTOInfo.Message) + DateTime.Now.ToString());
                //        }

                //        if (m_subscriptionDTO.SubscriptionType == "Paid")
                //        {


                //            registerForm.TotalAmount = m_subscriptionDTO.Amount;
                //            //create a card
                //            ExpMonth = registerForm.ExpMonth.Split('/')[0];
                //            ExpYear = registerForm.ExpMonth.Split('/')[1];

                //            MyUELHelpers.Info(typeof(RegisterController).ToString(), "SaveCardDetails", "Started " + DateTime.Now.ToString());
                //            CardDetailsDTO cardDetailsDTOInfo = null;
                //            cardDetailsDTOInfo = m_ICardDetailsBusiness.savecardDetails(registerForm.ccNo, registerForm.SecurityCode, ExpMonth, ExpYear, registerForm.UserEmail, APIKey, MyUserInfo);
                //            MyUELHelpers.Info(typeof(RegisterController).ToString(), "SaveCardDetails", "Ended " + DateTime.Now.ToString());
                //            if (cardDetailsDTOInfo != null)
                //            {
                //                //payment
                //                MyUELHelpers.Info(typeof(RegisterController).ToString(), "SavePaymentDetails", "Started " + DateTime.Now.ToString());
                //                CardPaymentDTOInfo = m_paymentDetailsBusiness.PaymentDetails(Convert.ToString(cardDetailsDTOInfo.Id), registerForm.TotalAmount, APIKey, MyUserInfo);
                //                MyUELHelpers.Info(typeof(RegisterController).ToString(), "SavePaymentDetails", "Done " + DateTime.Now.ToString());
                //                MyResultResponse.Status = CardPaymentDTOInfo.transactionstatus;
                //                MyResultResponse.Message = "Paid Subscription";

                //                MyRegisterFormResults.StatusCode = "PAYMENTDONESUCCESS";
                //                MyRegisterFormResults.Status = "Payment done subscription created";
                //                MyRegisterFormResults.Message = "Payment done subscription created";

                //                MyRegisterFormResults.PaymentId = CardPaymentDTOInfo.PaymentId;
                //                MyRegisterFormResults.TransactionId = CardPaymentDTOInfo.transactionId;
                //                //****************************************************************************************************************************************************************
                //                // Save In Payment Items
                //                //****************************************************************************************************************************************************************
                //                MyPaymentItems = new PaymentItems();

                //                MyPaymentItems.PaymentId = CardPaymentDTOInfo.id;
                //                MyPaymentItems.ItemName = "Subscription Charges";
                //                MyPaymentItems.PurchaseAmount = registerForm.TotalAmount;
                //                MyPaymentItems.NoOfUsers = NoOfUsers;
                //                PurchaseItemsId = m_IPurchaseUsersBusiness.CreatePaymentItems(MyPaymentItems, MyUserInfo);

                //                //****************************************************************************************************************************************************************

                //                //Send this Details to send the mail
                //                //MyRegisterFormResults.Subscription = m_subscriptionDTO;
                //                //MyRegisterFormResults.CardPayment = CardPaymentDTOInfo;
                //                //MyRegisterFormResults.User = UserDTOInfo;

                //                //TODO Send the email to user

                //            }
                //        }

                //        //Send Email After Register
                //        Subject = "User Registration Confirmation...";

                //        MyUserInfo.UserName = UserDTOInfo.UserName;
                //        MyUserInfo.Email = UserDTOInfo.UserEmail;
                //        MyUserInfo.Password = UserDTOInfo.UserPassword;

                //        MyUserInfo.SubscriptionName = SubscriptionName;

                //        //Template Parse
                //        TemplateParsers MyTemplateParser = new TemplateParsers(MyUserInfo);

                //        //Get After register html template from the Templates/AfterRegister.html
                //        var filePath = HttpContext.Current.Server.MapPath("~/Templates/AfterRegister.html");

                //        string html = File.ReadAllText(filePath);

                //        TemplateBody = MyTemplateParser.ParseAfterRegister(html, MyUserInfo);

                //        MessageBody = TemplateBody;

                //        //GET SMTP Settings
                //        SMTPSettings MyUELLoyaltySMTPSettings = new SMTPSettings();

                //        UtilityBusiness MyUtilityBusiness = new UtilityBusiness();
                //        BoundHoundSMTPSettings = MyUtilityBusiness.GetBoundHoundSMPTSettings(MyUserInfo);

                //        if (BoundHoundSMTPSettings != null)
                //        {
                //            if (BoundHoundSMTPSettings.Id > 0)
                //            {
                //                //string FromAddress = string.Format("{0} <{1}>", BoundHoundSMTPSettings.DisplayName, BoundHoundSMTPSettings.UserName);

                //                MyResultReponse = m_IEmailsBusiness.SendEmailAfterRegister(registerForm.UserEmail, BoundHoundSMTPSettings.HostName, BoundHoundSMTPSettings.Port, BoundHoundSMTPSettings.UserName,
                //                BoundHoundSMTPSettings.UserPassword,
                //                Subject, MessageBody, UserDTOInfo, m_subscriptionDTO, CardPaymentDTOInfo);

                //                //MyResultReponse = m_IEmailsBusiness.SendEmailAfterRegister(registerForm.UserEmail, MyUserInfo.FromUserEmail,
                //                //        MyUserInfo.FromPassword,
                //                //        Subject, MessageBody, UserDTOInfo, m_subscriptionDTO, CardPaymentDTOInfo);

                //                if (MyResultReponse.Status == "SUCCESS")
                //                {
                //                    MyRegisterFormResults.StatusCode = "USERREGISTER";
                //                    MyRegisterFormResults.Status = "User Registration Done";
                //                    MyRegisterFormResults.Message = "User Registration Done";
                //                    MyRegisterFormResults.User = UserDTOInfo;

                //                }
                //                else
                //                {
                //                    MyRegisterFormResults.StatusCode = "PAYMENTDONESUCCESS";
                //                    MyRegisterFormResults.Status = "Payment done subscription created";
                //                    MyRegisterFormResults.Message = "Payment done subscription created - Email error ";
                //                    MyRegisterFormResults.User = UserDTOInfo;
                //                }
                //            }
                //        }



                //        //SetupProcessDTOInfo = m_ISetupProcessBusiness.CreateTable("boundhound" + MyUserInfo.TenantId, MyUserInfo);

                //    }

                //}

                //else
                //{
                //    MyRegisterFormResults.Message = "InValid Subscription Id ";
                //    MyRegisterFormResults.User = UserDTOInfo;
                //}
                return(Json(MyRegisterFormResults));
            }
            catch (Exception Ex)
            {
                MyUELHelpers.ErrorLog(typeof(RegisterController).ToString(), "RegisterForm", Ex.ToString());
            }

            return(Json(MyRegisterFormResults));
        }
 public bool DeleteCardPayment(CardPaymentDTO item)
 {
     return(pssc.DeleteCardPayment(CardPaymentMapper.MapToDAO(item)));
 }
 public bool InsertCardPayment(CardPaymentDTO item)
 {
     return(pssc.InsertCardPayment(CardPaymentMapper.MapToDAO(item)));
 }
 public bool ChangeCardPayment(CardPaymentDTO item)
 {
     return(pssc.ChangeCardPayment(CardPaymentMapper.MapToDAO(item)));
 }