Esempio n. 1
0
        public Payment PayWithWallet(int orderid,double amount, ApplicationUser user)
        {
            
            

            var walletPayment = new Payment()
            {
                Amount = amount,
                ApplicationUserId = user.Id,
                // OrderID = orderid,
                Type = PaymentSort.Wallet
            };

            CreatePayment(walletPayment);
            _userManager.Pay(amount, user);
            return walletPayment;   
        }
Esempio n. 2
0
        // refunds the credit order to the users his wallet
        public void RefundCredit(int creditId)
        {

            CreditOrder creditOrder = _OrderRepository.FindCreditOrder(creditId);

            if(creditOrder.Paid == false)
            {
                UserManager _userManager = new UserManager();
                PaymentManager _paymentManager = new PaymentManager();

                int orderId = creditOrder.CreditForOrderId;
                KitchenOrder order = Find(orderId);
                ApplicationUser user = order.User;

                //set the order date edited to today
                creditOrder.DateEdited = DateTime.Now;
                UpdateOrder(orderId, order);

                // set credit order to paid
                creditOrder.Paid = true;
                _OrderRepository.UpdateCreditOrder(creditId, creditOrder);

                // create refund payment
                var payment = new Payment();
                payment.Amount = creditOrder.TotalAmount;
                payment.ApplicationUserId = creditOrder.ApplicationUserId;
                // payment.OrderID = orderId;
                payment.Type = PaymentSort.Wallet;
                _paymentManager.CreatePayment(payment);

                // recharge user wallet
                user.Wallet += Math.Abs(creditOrder.TotalAmount);
                _userManager.Update(user.Id, user);
            }
           
        }
Esempio n. 3
0
 //Het aanmaken van een payment
 public void CreatePayment(Payment payment)
 {
     _paymentRepository.PaymentCreate(payment);
 }