Exemplo n.º 1
0
        void PopulateOrders()
        {
            if (App.CheckoutItems == null)
            {
                return;
            }

            var foodItems = App.CheckoutItems.GroupBy(p => p.Id);

            foreach (var item in foodItems)
            {
                var food = item.FirstOrDefault();

                if (food == null)
                {
                    continue;
                }

                var order = new OrderDetail {
                    FoodId       = food.Id,
                    FoodName     = food.Name,
                    Quantity     = item.Count(),
                    SellingPrice = food.PricePerQty,
                };

                CheckoutItems.Add(new OrderDetailsViewModel(order, this));
            }

            if (CheckoutItems.Count <= 0)
            {
                return;
            }

            TotalPrice = CheckoutItems.Sum(p => p.Details.TotalPrice);
        }
Exemplo n.º 2
0
        public static void InitiateCheckout()
        {
            Guid userId = new Guid("92A8AA97-294C-487F-8B82-4DA9836C1136");
            User user   = DbCommonManager.GetUser(userId);

            Configuration config = new Configuration();

            config.PayUFailureUrl = "FailureUrl";
            config.PayUSuccessUrl = "SuccessUrl";
            config.PayUSalt       = "Salt";
            config.PayUKey        = "Key";

            PayUManager payUManager = new PayUManager(config);

            CheckoutRequest cr = new CheckoutRequest();

            cr.User                    = user;
            cr.DeliveryAddress         = new OrderDeliveryAddressMap();
            cr.DeliveryAddress.City    = "Bangalore";
            cr.DeliveryAddress.ZipCode = "560068";
            cr.DeliveryAddress.State   = "Karnataka";
            cr.DeliveryAddress.Address = "No 204 Sunnyvale apartment, 15th main road, AECS layout block A, Singasandra/Kudlu";

            CheckoutItems coi = new CheckoutItems();

            cr.CheckoutItems = coi;
            List <CheckoutItem> cil = new List <CheckoutItem>();
            CheckoutItem        ci  = new CheckoutItem();

            ci.SID       = 1;
            ci.Qty       = 1;
            ci.ID        = 1;
            ci.IPID      = 1;
            ci.CalcPrice = 135;
            cil.Add(ci);
            cr.CheckoutItems.Items          = cil.ToArray();
            cr.CheckoutItems.TotalCalcPrice = 135;

            CheckoutResponse response = payUManager.InitiateCheckout(cr);
        }
Exemplo n.º 3
0
        void CheckOutMethod()
        {
            if (string.IsNullOrEmpty(view.Address))
            {
                return;
            }

            var order = new Order {
                SpecialInstruction = view.Instructions,
                Address            = view.Address,
                UserId             = Settings.CurrentUserId,
                UserEmail          = "*****@*****.**",        //TODO: get user email address
                UserPhone          = "0918892320619",
                Payment            = "Cash On Delivery",
                UserName           = "******",       //TODO: get user name
                TotalAmount        = totalPrice,
                Discount           = 0,
                CouponId           = string.Empty,
                Status             = "Order Placed"
            };


            Debug.WriteLine(order.Id);

            foreach (var orderItem in CheckoutItems)
            {
                var detail = orderItem.Details;
                detail.OrderId = order.Id;
            }

            var orderItems = CheckoutItems.Select(x => x.Details).ToList();

            var vm = DependencyService.Get <IOrderViewModel> ();

            vm.SetOrderDetails(order, orderItems);
        }
Exemplo n.º 4
0
        public void UpdateTotalPrice()
        {
            TotalPrice = CheckoutItems.Sum(p => p.Details.TotalPrice);

            CalculateDiscount();
        }
Exemplo n.º 5
0
        public Status ProcessPayment(Payment payment)
        {
            if (payment == null ||
                string.IsNullOrWhiteSpace(payment.paymentId) ||
                string.IsNullOrWhiteSpace(payment.merchantTransactionId))
            {
                return(Status.InvalidInput);
            }

            long transactionId = -1;

            long.TryParse(payment.merchantTransactionId, out transactionId);
            Transaction transaction = CheckoutDbManager.GetTransaction(transactionId);

            if (transaction == null)
            {
                return(Status.InvalidTransaction);
            }
            Guid userId = Guid.Empty;

            if (!Guid.TryParse(payment.udf1, out userId))
            {
                return(Status.InvalidUserID);
            }
            if (string.IsNullOrWhiteSpace(transaction.ItemData))
            {
                return(Status.InvalidItem);
            }

            JsonSerializerHelper jsh           = new JsonSerializerHelper();
            CheckoutItems        checkoutItems = (CheckoutItems)jsh.Deserialize(transaction.ItemData, typeof(CheckoutItems));

            if (checkoutItems == null ||
                checkoutItems.Items == null ||
                checkoutItems.Items.Length <= 0)
            {
                return(Status.InvalidItem);
            }

            if (payment.amount != checkoutItems.TotalCalcPrice)
            {
                return(Status.InvalidAmount);
            }

            if (payment.status == "Success")
            {
                CheckoutDbManager.UpdateTransactionStatus(transactionId
                                                          , TransactionStatus.Paid);

                int receiptId = CheckoutDbManager.CreateReceipt(transaction.UserId
                                                                , transaction.TransactionId
                                                                , payment.paymentId
                                                                , (TransactionType)transaction.TransactionType
                                                                , TransactionProvider.PayU
                                                                , TransactionStatus.Paid);

                string rawReceipt = string.Empty;
                if (receiptId > 0)
                {
                    rawReceipt = jsh.Serialize(payment);
                    CheckoutDbManager.CreateRawReceipt(receiptId, rawReceipt);
                }
            }

            return(Status.Success);
        }