Esempio n. 1
0
        private void btnInsert_Click(object sender, RoutedEventArgs e)
        {
            if (txtCardHolderName.Text != "" &&
                txtCardNumber.Text != "" &&
                txtExpirationDate.Text != "" &&
                txtCVC.Text != "")
            {
                payment = new UserPayment()
                {
                    Id             = Guid.Empty,
                    UserId         = userId,
                    CardHolderName = txtCardHolderName.Text,
                    CardNumber     = txtCardNumber.Text,
                    ExpirationDate = txtExpirationDate.Text,
                    CVC            = txtCVC.Text
                };

                bool result = UserPaymentManager.Insert(payment);

                if (result)
                {
                    MessageBox.Show("Payment saved.");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("An error occurred when inserting.");
                }
            }
            else
            {
                MessageBox.Show("Error. Please enter data into the fields.");
            }
        }
        /// <summary>
        /// добавление инфы о платеже.
        /// </summary>
        /// <param name="payment">Экземпляр платежа пользователя, для которого ищем инфу о платеже.</param>
        public void AddUserPayment(UserPayment payment)
        {
            var dbPayment = Mapper.Map <DbUserPayment>(payment);

            _unitOfWork.UserPaymentRepository.Insert(dbPayment);
            _unitOfWork.SaveChanges();
        }
        public async Task<IActionResult> Register(UserPayment userPayment)
        {
            if (ModelState.IsValid)
            {
                UserApp userApp = new UserApp()
                {
                    Name= userPayment.UserName
                };

                _gameDbContext.UserApps.Add(userApp);
                _gameDbContext.SaveChanges();

                string IP = _accessor.HttpContext.Connection.RemoteIpAddress.ToString();

                int gameId = Convert.ToInt32(HttpContext.Session.GetString("gameId"));

                if (IP!=null)
                {
                    Payment payment = new Payment()
                    {
                        Amount = userPayment.Amount,
                        DateTime = userPayment.Date,
                        Status = true,
                        Ip = IP,
                        GameId=gameId
                    };

                    _gameDbContext.Payments.Add(payment);
                    _gameDbContext.SaveChanges();

                    return RedirectToAction("Index","Home");
                }
            }
            return View();
        }
Esempio n. 4
0
        public async Task <IActionResult> PutUserPayment(int id, UserPayment userPayment)
        {
            if (id != userPayment.UserPaymentId)
            {
                return(BadRequest());
            }

            _context.Entry(userPayment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserPaymentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 5
0
        public async Task <ActionResult <UserPayment> > PostUserPayment(UserPayment userPayment)
        {
            _context.UserPayment.Add(userPayment);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetUserPayment", new { id = userPayment.UserPaymentId }, userPayment));
        }
Esempio n. 6
0
        public static int Update(UserPayment userPayment)
        {
            try
            {
                using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities())
                {
                    tblUserPayment updatedrow = dc.tblUserPayments.FirstOrDefault(a => a.Id == userPayment.Id);

                    if (updatedrow != null)
                    {
                        updatedrow.UserId         = userPayment.UserId;
                        updatedrow.CardHolderName = userPayment.CardHolderName;
                        updatedrow.CardNumber     = userPayment.CardNumber;
                        updatedrow.ExpirationDate = userPayment.ExpirationDate;
                        updatedrow.CVC            = userPayment.CVC;


                        return(dc.SaveChanges());
                    }
                    else
                    {
                        return(0);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 7
0
        public async Task <ActionResult> Confirmation()
        {
            string code = "";

            if (User.Identity.IsAuthenticated)
            {
                //Envia um email com os dados da transação
                Email           email   = new Email();
                string          UserId  = User.Identity.GetUserId();
                Student         student = db.Students.Find(UserId);
                ApplicationUser user    = db.Users.Find(UserId);
                UserPayment     payment = db.UserPayments.Find(UserId);
                if (payment != null)
                {
                    code = payment.Txn_id;
                    string text = "Seu pagamento foi confirmado e sua recorrência está ativa." +
                                  "O código da sua transação é: " + code;

                    await email.Send(user.Email, student.FullName, "Confirmação de pagamento Speakster", "codigo da transação: " + code,
                                     "Olá " + student.First_name + ". Seu pagamento foi confirmado! <br/> Por favor, guarde o código da sua transação para sua segurança! <br/>"
                                     + "Código da transação: " + code + "<br/> Caso tenha alguma dúvida entre em contato com nosso suporte! <br/> Estamos muito felizes por ter você como nosso aluno! <br/> <a href='http://speakster.com.br'>SPEAKSTER</a> ");

                    return(View());
                }
            }
            return(RedirectToAction("Dashboard", "Users"));
        }
Esempio n. 8
0
        public static bool Insert(UserPayment userPayment)
        {
            try
            {
                using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities())
                {
                    // Make a new row
                    tblUserPayment newrow = new tblUserPayment();

                    // Set the properties
                    newrow.Id             = Guid.NewGuid();
                    newrow.UserId         = userPayment.UserId;
                    newrow.CardHolderName = userPayment.CardHolderName;
                    newrow.CardNumber     = userPayment.CardNumber;
                    newrow.ExpirationDate = userPayment.ExpirationDate;
                    newrow.CVC            = userPayment.CVC;

                    // Do the Insert
                    dc.tblUserPayments.Add(newrow);

                    // Commit the insert

                    return(Convert.ToBoolean(dc.SaveChanges()));
                }
            }
            catch (Exception ex)
            {
                //throw ex;
                return(false);
            }
        }
Esempio n. 9
0
        public IActionResult AddUser(UserPayment userPayment)
        {
            var test = userPayment.Name;

            //ProductService.SubmitName(userPayment.Name);
            return(Redirect("/"));
        }
        public async Task <IActionResult> CreatePaymentForFlat(int flatId, [FromBody] PaymentDTO paymentDTO, [FromHeader] List <int> userIds)
        {
            Payment payment = _mapper.Map <PaymentDTO, Payment>(paymentDTO);

            await _paymentsRepository.Add(payment);

            List <Payment> payments = await GetAllPaymentsFromFlatId(flatId);

            Flat flat = await _flatRepository.Get(flatId);

            payments.Add(payment);

            flat.Payments = payments;

            await _flatRepository.Update(flat);

            foreach (int userId in userIds)
            {
                User user = await _userRepository.Get(userId);

                UserPayment userPayment = new UserPayment {
                    Payment = payment, User = user, PaymentId = payment.Id, UserId = user.Id
                };

                user.UserPayments.Add(userPayment);

                await _userRepository.Update(user);
            }

            return(Ok(paymentDTO));
        }
Esempio n. 11
0
        private void ProcessVerificationResponse(IPNContext ipnContext)
        {
            if (ipnContext.Verification.Equals("VERIFIED"))
            {
                var paymentInfo = ipnContext.RequestBody;
                var payment     = new UserPayment();
                payment.Summ         = decimal.Parse(GetFromSpam("mc_gross", paymentInfo).Replace(".", ","));
                payment.PaymentID    = GetFromSpam("payer_id", paymentInfo);
                payment.Result       = GetFromSpam("payment_status", paymentInfo);
                payment.FirstName    = GetFromSpam("first_name", paymentInfo);
                payment.CustomString = GetFromSpam("custom", paymentInfo);
                payment.Email        = GetFromSpam("payer_email", paymentInfo);
                payment.LastName     = GetFromSpam("last_name", paymentInfo);
                payment.Currentcy    = GetFromSpam("mc_currency", paymentInfo);
                payment.UserId       = GetFromSpam("custom", paymentInfo);

                _userPaymentService.AddUserPayment(payment);

                if ((payment.Result == "Completed") && (payment.Summ == 3))
                {
                    var accountLevel = new AccountLevel();
                    accountLevel.Id   = 2;
                    accountLevel.Name = "Премиум";
                    _userAccountLevelService.SetUserAccountLevel(int.Parse(payment.UserId), accountLevel);
                }
            }
            else if (ipnContext.Verification.Equals("INVALID"))
            {
                //Log for manual investigation
            }
            else
            {
                //Log error
            }
        }
Esempio n. 12
0
        public void DeleteTest()
        {
            List <UserPayment> paymethods = UserPaymentManager.Load();
            UserPayment        paymethod  = paymethods.Where(c => c.CardHolderName == "John Test Hancook").FirstOrDefault();
            int actual = UserPaymentManager.Delete(paymethod.Id);

            Assert.IsTrue(actual > 0);
        }
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            user = new User()
            {
                Id        = Guid.Empty,
                FirstName = txtFirstName.Text,
                LastName  = txtLastName.Text,
                Email     = txtEmail.Text,
                Phone     = txtPhone.Text,
                Password  = txtPassword.Password
            };

            int result = UserManager.Insert(user);

            if (result >= 1)
            {
                payment = new UserPayment()
                {
                    Id             = Guid.Empty,
                    UserId         = user.Id,
                    CardHolderName = txtCardHolderName.Text,
                    CardNumber     = txtCardNumber.Text,
                    ExpirationDate = txtExpirationDate.Text,
                    CVC            = txtCVC.Text
                };

                address = new UserAddress()
                {
                    Id      = Guid.Empty,
                    UserId  = user.Id,
                    Address = txtAddress.Text,
                    City    = txtCity.Text,
                    StateId = cboState.SelectedIndex,
                    ZipCode = txtZip.Text
                };

                Guid id = user.Id;

                bool paymentresult = UserPaymentManager.Insert(payment);
                bool addressresult = UserAddressManager.Insert(address);

                if (paymentresult && addressresult)
                {
                    this.Close();
                    new LoginWindow().ShowDialog();
                }
                else
                {
                    UserManager.Delete(user.Id);
                    MessageBox.Show("An Error Occurred. Invaild Data Entered for Address or Payment");
                }
            }
            else
            {
                MessageBox.Show("An Error Occurred. Invalid Data Entered for User.");
            }
        }
Esempio n. 14
0
        public ActionResult AddPaymentLine(PG_ListViewModel input)
        {
            IsAddPaymentLine = true;

            PaymentsGroup g = db.PaymentsGroups.Find(input.Header.PaymentsGroupId);

            if (g != null)
            {
                if (!string.IsNullOrEmpty(input.NewUserPaymentName) && input.NewUserPaymentProject != null && input.NewUserPaymenSum != null)
                {
                    var b = db.UserBalances.SingleOrDefault(x => x.User.FullName == input.NewUserPaymentName && x.Project.ProjectId == input.NewUserPaymentProject);
                    if (b != null)
                    {
                        var pm = g.UsersPayments.FirstOrDefault(x => x.Project.ProjectId == input.NewUserPaymentProject);
                        if (pm == null)
                        {
                            if (b.Sum >= (int)input.NewUserPaymenSum && (int)input.NewUserPaymenSum != 0)
                            {
                                UserPayment p = new UserPayment()
                                {
                                    User         = b.User,
                                    Project      = b.Project,
                                    Sum          = (double)input.NewUserPaymenSum,
                                    PaymentGroup = db.PaymentsGroups.Find(input.Header.PaymentsGroupId)
                                };
                                db.UserPayments.Add(p);
                                db.SaveChanges();

                                input = getPG_ListsViewModel(input.Header.PaymentsGroupId);
                            }
                            else
                            {
                                ModelState.AddModelError("", "Ошибка, сумма платежа превышает баланс или равна нулю");
                                input.NewUserPaymentName = "";
                                return(View("Edit", input));
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("", "Ошибка, выплата по проекту уже есть в ведомости");
                            input.NewUserPaymentName = "";
                            return(View("Edit", input));
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Ошибка, нет выплат по проекту");
                        input.NewUserPaymentName = "";
                        return(View("Edit", input));
                    }
                }
            }
            input.NewUserPaymentName = "";
            return(Edit(input));
        }
Esempio n. 15
0
        private static bool ChargePayment(UserPayment user)
        {
            //TODO: this will come from config
            RestClient client = new RestClient("http://thirdparty:9075/api/");
            // request
            RestRequest request = new RestRequest("Products", Method.POST);
            //response
            IRestResponse <bool> response = client.Execute <bool>(request);

            return(response.Data);
        }
Esempio n. 16
0
        public PaymentWindow(Guid paymentid, Guid userid)
        {
            payment = UserPaymentManager.LoadByUserAndPaymentId(paymentid, userid);

            InitializeComponent();

            txtCardHolderName.Text = payment.CardHolderName;
            txtCardNumber.Text     = payment.CardNumber;
            txtExpirationDate.Text = payment.ExpirationDate;
            txtCVC.Text            = payment.CVC;
        }
Esempio n. 17
0
        public async Task <bool> Charge(UserPayment userpayment)
        {
            //Validate user , payment info.etc
            //We dont want to place false call the third part web service

            // Provide proper secuurity / authrization details and call third party service
            if (IsValidPaymentInfo(userpayment))
            {
                return(await ChargePayment(userpayment.PaymentInformation.CardNumber, userpayment.AmountToBeCharged));
            }
            return(false);
        }
Esempio n. 18
0
        public async Task <IActionResult> AddUserToExistingPayment(int paymentId, [FromQuery] int userId)
        {
            Payment payment = await _paymentsRepository.Get(paymentId);

            User user = await _userRepository.Get(userId);

            UserPayment userPayment = new UserPayment {
                UserId = userId, PaymentId = paymentId, User = user, Payment = payment
            };

            await _userPaymentsRepository.Add(userPayment);

            return(NoContent());
        }
Esempio n. 19
0
        private static UserPayment[] SeedUserPayments(User[] users, CreditCard[] creditCards, BankAccount[] bankAccounts)
        {
            var paymentMethod1 = new UserPayment(users[0], PaymentType.CreditCard, creditCards[0]);
            var paymentMethod2 = new UserPayment(users[0], PaymentType.BankAccount, bankAccounts[0]);
            var paymentMethod3 = new UserPayment(users[0], PaymentType.BankAccount, bankAccounts[1]);

            //// Test Index -> the unique combination of UserId, BankAccountId and CreditCardId
            //var paymentMethod_testIndex = new UserPayment(users[0], PaymentType.CreditCard, creditCards[0]);

            //// Test Check Constraint -> always one of BankAccountId and CreditCardId is null and the other one is not
            //paymentMethod1.BankAccount = bankAccounts[0];

            var paymentMethods = new UserPayment[] { paymentMethod1, paymentMethod2, paymentMethod3 };

            return(paymentMethods);
        }
Esempio n. 20
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Hello Lab!");
                Console.WriteLine("You can use this application to place an order for a single product. Do you want to procceed? ");
                var input = Console.ReadLine();
                if (string.Equals(input, "Y", StringComparison.CurrentCultureIgnoreCase) ||
                    string.Equals(input, "Yes", StringComparison.CurrentCultureIgnoreCase))
                {
                    Console.WriteLine("Lets start. What product id you want?");
                    var productid = Console.ReadLine();

                    //Check inventory
                    Console.WriteLine("Thanks. Checking inventory...");

                    bool isProductAvailableToSell = CheckProductAvailability(productid);

                    //Payment gateway
                    if (isProductAvailableToSell)
                    {
                        Console.WriteLine("Good news ! Product is available. We need you payment information to procced further.");
                        UserPayment user = GetUserInformation();

                        Console.WriteLine("Ready? Press Y to proceed. This will charge your account and ship the product to you.");
                        if (string.Equals(input, "Y", StringComparison.CurrentCultureIgnoreCase))
                        {
                            Order order   = CreateOrder(user, productid);
                            bool  charged = ProcessOrder(order);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Product is not available anymore or  web service is not runninng ( in that case, Please run web service first.)");
                        Console.ReadLine();
                    }
                }
                Console.WriteLine("Have a great day ! Type anything to exit.");
                Console.ReadLine();
            }
            catch (SystemException ex)
            {
                Console.WriteLine("Something went wrong. Check if web service is running.");
                Console.ReadLine();
            }
        }
Esempio n. 21
0
        public void InsertTest()
        {
            Guid userId = UserManager.Load().FirstOrDefault().Id;

            UserPayment userpayment = new UserPayment
            {
                UserId         = userId,
                CardHolderName = "John Hancock",
                CardNumber     = "1234432109877890",
                ExpirationDate = "0222",
                CVC            = "123"
            };

            bool result = UserPaymentManager.Insert(userpayment);

            Assert.IsTrue(result);
        }
Esempio n. 22
0
        public UserPayment CreatePayment(string userId, decimal amount)
        {
            var payment = new UserPayment()
            {
                UserId = userId,
                Amount = amount,
                ID     = Guid.NewGuid(),
                State  = UserPaymentState.Created,
                Date   = DateTime.Now
            };

            _paymentContext.Payments.Add(payment);

            _paymentContext.SaveChanges();

            return(payment);
        }
Esempio n. 23
0
 private UserPayment setPaymentInfo(UserPayment user_payment)
 {
     user_payment.User_id         = getRequest("custom");
     user_payment.Payment_status  = getRequest("payment_status");
     user_payment.Address_city    = getRequest("address_city");
     user_payment.Address_country = getRequest("address_country");
     user_payment.Address_state   = getRequest("address_state");
     user_payment.Address_zip     = getRequest("address_zip");
     user_payment.First_name      = getRequest("first_name");
     user_payment.Last_name       = getRequest("last_name");
     user_payment.Payer_email     = getRequest("payer_email");
     user_payment.Payment_date    = getRequest("payment_date");
     user_payment.Receiver_email  = getRequest("receiver_email");
     //user_payment.Subscr_date = Request["subscr_date"].ToString();
     user_payment.Txn_id   = getRequest("txn_id");
     user_payment.Txn_type = getRequest("txn_type");
     return(user_payment);
 }
Esempio n. 24
0
 private static Order CreateOrder(UserPayment user, string productid)
 {
     return(new Order()
     {
         Item = new Product()
         {
             ProductId = productid
         },
         Payment = new UserPayment()
         {
             AmountToBeCharged = Convert.ToDecimal("0.02"), Name = user.Name
         },
         ShippingAddress = new ShippingInfo()
         {
             Address = "no mans land"
         }
     });
 }
Esempio n. 25
0
        public static long SaveUserPayment(QuiGigAPIEntities context, string userId, string provider, long planID, decimal durationAmount, string description, string token, string transactionId, long packgId, string paymentFrom, string paymentStatus)
        {
            long id = 0;

            try
            {
                var providerDetail = context.PaymentSubscriptions.Where(x => x.Provider.ToLower() == provider.ToLower() && x.IsActive == true).FirstOrDefault();
                if (providerDetail != null)
                {
                    UserPayment entity = new UserPayment();
                    entity.ProviderId = providerDetail.ID;
                    entity.UserID     = userId;
                    if (planID > 0)
                    {
                        entity.UserPlanId = planID;
                    }
                    entity.Token         = token;
                    entity.Amount        = durationAmount;
                    entity.PaymentStatus = paymentStatus;
                    entity.PaymentFrom   = paymentFrom;
                    if (!string.IsNullOrEmpty(transactionId))
                    {
                        entity.TransactionId = transactionId;
                    }
                    entity.CreatedDate = DateTime.UtcNow;
                    entity.Description = description;
                    if (packgId > 0)
                    {
                        entity.PackageId = packgId;
                    }
                    context.UserPayments.Add(entity);
                    context.SaveChanges();
                    id = entity.ID;
                }
            }
            catch (Exception ex)
            {
            }
            return(id);
        }
Esempio n. 26
0
        public async Task <IActionResult> CreatePaymentForFlat([FromBody] PaymentDTO paymentDTO, [FromHeader] List <int> userIds)
        {
            ClaimsIdentity identity = HttpContext.User.Identity as ClaimsIdentity;

            int userID = Int16.Parse(identity.FindFirst(ClaimTypes.NameIdentifier).Value);

            var usr = await _userRepository.Get(userID);

            int?flatId = usr.FlatId;

            Payment payment = _mapper.Map <PaymentDTO, Payment>(paymentDTO);

            await _paymentsRepository.Add(payment);

            List <Payment> payments = await GetAllPaymentsFromFlatId(flatId);

            Flat flat = await _flatRepository.Get(flatId.Value);

            payments.Add(payment);

            flat.Payments = payments;

            await _flatRepository.Update(flat);

            foreach (int userId in userIds)
            {
                User user = await _userRepository.Get(userId);

                UserPayment userPayment = new UserPayment {
                    Payment = payment, User = user, PaymentId = payment.Id, UserId = user.Id
                };

                user.UserPayments.Add(userPayment);

                await _userRepository.Update(user);
            }

            return(Ok(paymentDTO));
        }
Esempio n. 27
0
        public async Task <IActionResult> Post([FromBody] UserPayment user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data."));
            }
            _logger.LogInformation("PaymentsController.Post: ");

            bool charged = false;

            try
            {
                charged = await _paymentService.Charge(user);

                _logger.LogInformation("Out from PaymentsController.Post: ");
                return(Ok(charged));
            }
            catch (SystemException ex)
            {
                _logger.LogInformation($"Exception occurred: {ex.Message} ");
                return(Ok(charged));
            }
        }
Esempio n. 28
0
        public ActionResult PaymentDetails(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserPayment userPayment = db.UserPayments.Find(id);

            if (userPayment.isActive())
            {
                ViewBag.isActive = "Ativa";
            }
            else
            {
                ViewBag.isActive = "Inativa";
            }

            if (userPayment == null)
            {
                return(HttpNotFound());
            }
            return(View(userPayment));
        }
Esempio n. 29
0
 // PUT: api/UserPayment/5
 public void Put(Guid id, [FromBody] UserPayment make)
 {
     UserPaymentManager.Update(make);
 }
Esempio n. 30
0
 // POST: api/UserPayment
 public void Post([FromBody] UserPayment make)
 {
     UserPaymentManager.Insert(make);
 }