Ejemplo n.º 1
0
        public decimal SaveGatewayOrder(PaymentGateWay paymentGateWay, string orderRef)
        {
            var order = _orderRepository.FirstOrDefault(x => x.OrderRef == orderRef);

            if (order == null || order.Paid)
            {
                throw new Exception(ExceptionInfo.OrderNotExistsOrIsPaid);
            }
            var payment = new Payment
            {
                OrderRef      = orderRef,
                Amount        = order.Total,
                DateCreated   = DateTime.Now,
                PaymenGateway = paymentGateWay
            };

            return(_paymentRepository.Insert(payment).Amount);
        }
Ejemplo n.º 2
0
        public bool GetOrderPaidStatus(string xmlParamter, PaymentGateWay paymentGateWay)
        {
            PayResult result =
                paymentGateWay == PaymentGateWay.WeiXinPay ?
                _iWeiXinPayService.GetOrderPaidStatus(xmlParamter)
                : _iAliPayService.GetOrderPaidStatus(xmlParamter);

            if (result.IsSuccess == false)
            {
                return(result.IsSuccess);
            }
            var order = _orderRepository.FirstOrDefault(x => x.OrderRef == result.OrderRef);

            order.Paid = true;
            var payment = _paymentRepository.FirstOrDefault(x => x.OrderRef == result.OrderRef);

            payment.PaymenGateway = paymentGateWay;
            payment.GatewayRef    = result.GatewayRef;
            payment.Paid          = true;
            payment.DatePaid      = DateTime.Now;
            _orderRepository.Update(order);
            _paymentRepository.Update(payment);
            return(result.IsSuccess);
        }
Ejemplo n.º 3
0
        public List <PaymentGateWay> GetPayGateWay(string BN)
        {
            try
            {
                // get Some data from DB like Currency and pos
                PayLinkDB             DB = new PayLinkDB();
                SalesRulesManager     ServiceChargeManager = new SalesRulesManager();
                string                pos;
                List <string>         gates           = new List <string>();
                List <PaymentGateWay> paymentGateWays = new List <PaymentGateWay>();
                //    SalesRuleGateway salesRule = new SalesRuleGateway();
                SalesRules salesRule = new SalesRules();
                var        criterais = DB.GetDataForGatewayDA(BN);
                //call selected Gateway
                //basecurr
                var BaseCur = ConfigurationSettings.AppSettings["BaseCur"];
                // exchangeRate
                CurrencyRepo currencyManager = new CurrencyRepo();

                double ExcahngeRate        = currencyManager.GetEveryDayCurrenciesConversion(BaseCur, criterais.Curr, criterais.searchData.sID, DateTime.Now).Result.Customer_Sell_Rate;
                double ExcahngeRateForBase = currencyManager.GetEveryDayCurrenciesConversion(criterais.Curr, BaseCur, criterais.searchData.sID, DateTime.Now).Result.Customer_Sell_Rate;

                if (criterais.Curr != null & criterais.pos != null)
                {
                    gates = GateWays.GetPaymentGatewaysAsync(criterais.Curr).Result;
                    if (gates.Count == 0)
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
                // call sales Rules
                salesRule = GateWays.GetSaleRuleForGateAsync(criterais.pos).Result;

                if (salesRule.MarkupList.Count == 0)
                {
                    foreach (var item in gates)
                    {
                        PaymentGateWay gateWay = new PaymentGateWay();
                        gateWay.paymentMethod = item;
                        gateWay.currency      = criterais.Curr;
                        gateWay.amount        = 0;

                        paymentGateWays.Add(gateWay);
                    }
                    return(paymentGateWays);
                }
                ServiceChargeManager.FillPaySaleRules(salesRule);

                ServiceChargeManager.PrepareSearchCriteriaDic(criterais.searchData);

                foreach (var item in gates)
                {
                    ServiceChargeManager.SetResultCriteriaForpay(criterais.HotelName, criterais.HotelStars, criterais.cost
                                                                 * ExcahngeRateForBase, criterais.Pid, item);
                    //AppliedSalesRule AppliedMarkup = ServiceChargeManager.ApplySalesRules("Markup");
                    AppliedSalesRule AppliedMarkup = ServiceChargeManager.ApplyMarkupForPayGateway();
                    PaymentGateWay   gateWay       = new PaymentGateWay();
                    gateWay.paymentMethod = item;
                    gateWay.currency      = criterais.Curr;
                    if (gateWay.currency.ToLower() == "kwd")
                    {
                        gateWay.amount = Math.Round(AppliedMarkup.Value * ExcahngeRate, 3);
                    }

                    gateWay.amount = Math.Round(AppliedMarkup.Value * ExcahngeRate, 2);


                    paymentGateWays.Add(gateWay);
                }
                return(paymentGateWays);

                ///    AppliedSalesRule AppliedDiscount = ServiceChargeManager.ApplySalesRules("Discount");
                // map

                /*  foreach (var item in salesRule.MarkupList)
                 * {
                 *    foreach (var gate in item.CriteriaList)
                 *    {
                 *        foreach (var g in gates)
                 *        {
                 *
                 *
                 *            if (g.ToLower() == gate.value.ToLower())
                 *            {
                 *                PaymentGateWay gateWay = new PaymentGateWay();
                 *                gateWay.paymentMethod = g;
                 *                gateWay.currency = BaseCur;
                 *              gateWay.amount = item.commAmount;
                 *                gateWay.exchangeRate = ExcahngeRate;
                 *                paymentGateWays.Add(gateWay);
                 *            }
                 *        }
                 *    }
                 * }*/
            }
            catch (Exception ex)
            {
                return(null);
            }
        }