public int InsertToPaymentGatewayRecord(OrderViewModel orderViewModel, Guid authToken, ref decimal amount) { try { var errors = new List <ValidationErrorViewModel>(); var myHlShoppingCart = _mobileQuoteHelper.PriceCart(ref orderViewModel, ref errors); if (null != errors && errors.Any()) { return(0); } var orderTotalsV01 = myHlShoppingCart.Totals as ServiceProvider.OrderSvc.OrderTotals_V01; var orderTotalsV02 = myHlShoppingCart.Totals as ServiceProvider.OrderSvc.OrderTotals_V02; var order = MobileOrderProvider.ModelConverter.ConvertOrderViewModelToOrderV01(orderViewModel, ref errors, orderTotalsV02, orderTotalsV01, out amount); var countryCode = orderViewModel.Locale.Substring(3, 2); if (amount > 0) { var orderNumber = GetOrderNumber(amount, countryCode, orderViewModel.OrderMemberId); orderViewModel.OrderNumber = orderNumber; } else { return(0); } var btOrder = OrderProvider.CreateOrder(order, myHlShoppingCart, countryCode, null, "Mobile"); if (((ServiceProvider.SubmitOrderBTSvc.Order)btOrder).Payments != null) { ((ServiceProvider.SubmitOrderBTSvc.Order)btOrder).OrderID = orderViewModel.OrderNumber; ((ServiceProvider.SubmitOrderBTSvc.Order)btOrder).Payments[0].NumberOfInstallments = 1; ((ServiceProvider.SubmitOrderBTSvc.Order)btOrder).Payments[0].NameOnAccount = "China User"; ((ServiceProvider.SubmitOrderBTSvc.Order)btOrder).Payments[0].Currency = "RMB"; } var holder = OrderProvider.GetSerializedOrderHolder(btOrder, order, myHlShoppingCart, authToken == Guid.Empty ? Guid.NewGuid() : authToken); var orderData = OrderSerializer.SerializeOrder(holder); return(OrderProvider.InsertPaymentGatewayRecord(orderViewModel.OrderNumber, orderViewModel.MemberId, "WechatPayment", orderData, orderViewModel.Locale)); } catch (Exception ex) { LoggerHelper.Exception("System.Exception", ex, "Exception in InsertToPaymentGatewayRecord method MobileWechatProvider"); return(0); } }
public QuoteResponseViewModel Quote(OrderViewModel order, ref List <ValidationErrorViewModel> errors) { try { if (null == errors) { errors = new List <ValidationErrorViewModel>(); } if (ValidateOrderViewModel(order)) { if (_mobileQuoteHelper.CheckIfOrderCompleted(order.Id)) { errors.Add( new ValidationErrorViewModel { Code = 109999, Reason = string.Format("order for guid {0} already completed", order.Id) }); string countrydup = order.Locale.Substring(3, 2); DualOrderMonthViewModel orderMonthDatadup = _dualOrderMonthProvider.GetDualOrderMonth(countrydup); return(new QuoteResponseViewModel { Order = order, DualOrderMonth = new DualOrderMonthViewModel { PreviousOrderMonthEndDate = orderMonthDatadup != null ? orderMonthDatadup.PreviousOrderMonthEndDate : string.Empty, PreviousOrderMonth = orderMonthDatadup != null ? orderMonthDatadup.PreviousOrderMonth : 0, }, }); } var shoppingCart = _mobileQuoteHelper.PriceCart(ref order, ref errors, checkSkuAvalability: true, checkUnSupportedAddress: true); if (shoppingCart != null) { var ruleErrors = CheckForError(shoppingCart.RuleResults); if (null != ruleErrors && ruleErrors.Any()) { errors.AddRange(ruleErrors); } if (errors != null && errors.Count > 1 && errors.Find(f => f.Code.Equals(110430)) != null) { errors.RemoveAll(e => e.Code.Equals(10416)); } string country = order.Locale.Substring(3, 2); DualOrderMonthViewModel orderMonthData = _dualOrderMonthProvider.GetDualOrderMonth(country); var dualOrderMonth = new DualOrderMonthResponseViewModel { PreviousOrderMonth = orderMonthData != null? orderMonthData.PreviousOrderMonth :0, PreviousOrderMonthEndDate = orderMonthData != null? orderMonthData.PreviousOrderMonthEndDate : string.Empty }; var result = new QuoteResponseViewModel { Order = order, DualOrderMonth = new DualOrderMonthViewModel { PreviousOrderMonthEndDate = dualOrderMonth.PreviousOrderMonthEndDate, PreviousOrderMonth = dualOrderMonth.PreviousOrderMonth }, }; SaveMobileQuoteResponse(result, shoppingCart.ShoppingCartID); return(result); } } errors.Add( new ValidationErrorViewModel { Code = 100416, Reason = "Quote failed" }); return(new QuoteResponseViewModel { Order = order, }); } catch (Exception ex) { LoggerHelper.Exception("System.Exception", ex, "Exception in Quote method MobileQuoteProvider"); errors.Add( new ValidationErrorViewModel { Code = 100416, Reason = "Quote failed" }); return(new QuoteResponseViewModel { Order = order, }); } }
public OrderResponseViewModel RequestMobilePin(OrderRequestViewModel request) { string obj = JsonConvert.SerializeObject(request); List <ValidationErrorViewModel> errors = null; request.Data.OrderMemberId = string.IsNullOrEmpty(request.Data.OrderMemberId) && !string.IsNullOrEmpty(request.Data.CustomerId) ? request.Data.CustomerId : request.Data.OrderMemberId; var viewModel = request.Data; var shoppingcart = _mobileQuoteHelper.PriceCart(ref viewModel, ref errors); var quickPayresponseviewModel = new OrderResponseViewModel(); if (null != errors && errors.Any()) { quickPayresponseviewModel.ValidationErrors = errors; return(quickPayresponseviewModel); } var orderTotalsV01 = shoppingcart.Totals as ServiceProvider.OrderSvc.OrderTotals_V01; var orderTotalsV02 = shoppingcart.Totals as ServiceProvider.OrderSvc.OrderTotals_V02; decimal amount; var order = _mobileQuickPayController.Getorder(viewModel, ref errors, orderTotalsV02, orderTotalsV01, out amount); var ordernumber = order.OrderID; if (string.IsNullOrWhiteSpace(ordernumber)) { ordernumber = _mobileQuickPayController.GetOrderNumber(amount, shoppingcart.CountryCode, shoppingcart.DistributorID); } //Order_V01 order, string ordernumber, MyHLShoppingCart cart var cn99BillQuickPayProvider = new CN_99BillQuickPayProvider(); var hasrequestedmobilepin = cn99BillQuickPayProvider.RequestMobilePinForPurchase(ordernumber, order, shoppingcart, request.Data.MemberId); if (hasrequestedmobilepin) { var quickPayPaymentViewModel = request.Data.Payments[0] as QuickPayPaymentViewModel; if (quickPayPaymentViewModel != null) { quickPayPaymentViewModel.StorablePAN = cn99BillQuickPayProvider.StorablePAN; quickPayPaymentViewModel.Token = cn99BillQuickPayProvider.Token; } viewModel.OrderNumber = ordernumber; } if (!string.IsNullOrEmpty(cn99BillQuickPayProvider.LastErrorMessage)) { if (errors == null) { errors = new List <ValidationErrorViewModel>(); } errors.Add(new ValidationErrorViewModel { Code = 126000, Reason = cn99BillQuickPayProvider.LastErrorMessage }); } quickPayresponseviewModel.Data = viewModel; if (null != errors && errors.Any()) { quickPayresponseviewModel.ValidationErrors = errors; } JObject json = JObject.Parse(obj); MobileActivityLogProvider.ActivityLog(json, quickPayresponseviewModel, request.Data.MemberId, true, this.Request.RequestUri.ToString(), this.Request.Headers.ToString(), this.Request.Headers.UserAgent.ToString(), request.Data.Locale); return(quickPayresponseviewModel); }