protected void btnSubmit_Click(object sender, EventArgs e) { if (ShoppingCart != null) { ShoppingCart.CheckAPFShipping(); // Set the order var order = OrderCreationHelper.CreateOrderObject(ShoppingCart) as Order_V01; order.DistributorID = DistributorID; order.CountryOfProcessing = CountryCode; order.ReceivedDate = DateUtils.GetCurrentLocalTime(CountryCode); order.OrderMonth = GetOrderMonthShortString(); order.OrderCategory = (CountryCode == "GR") ? OrderCategoryType.APF : OrderCategoryType.RSO; //** RSO is just for testing (using other countries) and will always be APF order.Shipment = OrderProvider.CreateShippingInfo(CountryCode, ShoppingCart); order.Handling = OrderProvider.CreateHandlingInfo(CountryCode, string.Empty, ShoppingCart, order.Shipment as ShippingInfo_V01); List <Payment> payments = null; if (PaymentOptions != null) { if (PaymentOptions.ValidateAndGetPayments(ObjectMappingHelper.Instance.GetToOrder(ShoppingCart.DeliveryInfo.Address.Address), out payments)) { if (payments != null && payments.Count > 0) { order.Payments = new PaymentCollection(); order.Payments.AddRange((from p in payments select p).ToArray()); } order = OrderProvider.PopulateLineItems(CountryCode, order, ShoppingCart) as Order_V01; order.DiscountPercentage = (ShoppingCart.Totals as OrderTotals_V01).DiscountPercentage; var theOrder = OrderProvider.CreateOrder(order, ShoppingCart, CountryCode); List <FailedCardInfo> failedCards = null; string error = string.Empty; string orderID = OrderProvider.ImportOrder(theOrder, out error, out failedCards, ShoppingCart.ShoppingCartID); if (string.IsNullOrEmpty(error)) { // TODO: how to get auth token ShoppingCartProvider.UpdateShoppingCart(ShoppingCart, OrderProvider.SerializeOrder(theOrder, order, ShoppingCart, new Guid()), orderID, order.ReceivedDate); if (string.IsNullOrEmpty(order.OrderID)) { order.OrderID = orderID; order.Pricing = ShoppingCart.Totals; } if (!String.IsNullOrEmpty(ShoppingCart.EmailAddress)) { EmailHelper.SendEmail(ShoppingCart, order); } onHFFOrderPlaced(this, new EventArgs()); } } } } }
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 static MobilePghOrderResponseViewModel InsertPghOrder(MobilePghOrderRequestViewModel request, out List <ValidationErrorViewModel> validationErrors) { Thread.CurrentThread.Name = request.Client.Name == "ikiosk" ? "iKiosk" : request.Client.Name; var memberId = string.Empty; validationErrors = null; var response = new MobilePghOrderResponseViewModel(); if (null == request || null == request.Data || null == request.InvoiceData) { return(response); } try { var order = new Order_V01(); var shoppingCart = new MyHLShoppingCart(); var countryCode = request.Data.Locale.Substring(3, 2); memberId = request.Data.DistributorId; var totals = ConvertToOrderTotals(request.InvoiceData, countryCode); if (totals == null) { validationErrors.Add(new ValidationErrorViewModel { Code = 0, Reason = "Error on Totals is null value." }); return(response); } GenerateObject(request, out order, out shoppingCart, totals); var btOrder = OrderProvider.CreateOrder(order, shoppingCart, countryCode); if (null != btOrder && request.Client.Name == "ikiosk") { ((ServiceProvider.SubmitOrderBTSvc.Order)btOrder).InputMethod = "IK"; } var amount = GetAmountdue(request.InvoiceData); var orderNumber = GetOrderNumber(amount, shoppingCart.CountryCode, shoppingCart.DistributorID); var holder = OrderProvider.GetSerializedOrderHolder(btOrder, order, shoppingCart, new Guid()); var orderData = OrderSerializer.SerializeOrder(holder); var gatewayName = HLConfigManager.Configurations.PaymentsConfiguration.GatewayName; var netbankingName = "TechProcessPaymentGateway"; var paymentTypeDefault = "CreditCard"; var selectedGateway = request.Data.PaymentInfo.IssuerAssociation.PaymentType.ToUpper() == paymentTypeDefault.ToUpper() ? gatewayName : netbankingName; var paymentId = OrderProvider.InsertPaymentGatewayRecord(orderNumber, memberId, selectedGateway, orderData, request.Data.Locale); if (paymentId > 0) { response.OrderNumber = orderNumber; response.Status = true; return(response); } } catch (Exception ex) { validationErrors = new List <ValidationErrorViewModel> { new ValidationErrorViewModel { Code = 0, Reason = ex.Message } }; } response.OrderNumber = string.Empty; response.Status = false; return(response); }
protected void btnSubmit_Click(object sender, EventArgs e) { var _errors = new List <string>(); if (ShoppingCart != null) { if (ShoppingCart.Totals == null) { ShoppingCart.Calculate(); } // Set the order var order = OrderCreationHelper.CreateOrderObject(ShoppingCart) as Order_V01; order.DistributorID = DistributorID; order.CountryOfProcessing = CountryCode; order.ReceivedDate = DateUtils.GetCurrentLocalTime(CountryCode); order.OrderMonth = GetOrderMonthShortString(); order.OrderCategory = (OrderCategoryType) Enum.Parse(typeof(OrderCategoryType), HLConfigManager.Configurations.DOConfiguration.HFFModalOrderType); order.Shipment = OrderProvider.CreateShippingInfo(CountryCode, ShoppingCart); var provider = (Page as ProductsBase).GetShippingProvider(); (order.Shipment as ShippingInfo_V01).Address = ObjectMappingHelper.Instance.GetToOrder(provider.GetHFFDefaultAddress(ShoppingCart.DeliveryInfo.Address)); order.Handling = OrderProvider.CreateHandlingInfo(CountryCode, string.Empty, ShoppingCart, order.Shipment as ShippingInfo_V01); List <Payment> payments = null; if (PaymentOptions != null) { if (PaymentOptions.ValidateAndGetPayments(ObjectMappingHelper.Instance.GetToOrder(ShoppingCart.DeliveryInfo.Address.Address), out payments)) { if (payments != null && payments.Count > 0) { order.Payments = new PaymentCollection(); order.Payments.AddRange((from p in payments select p).ToArray()); } HLRulesManager.Manager.PerformTaxationRules(order, (Page as ProductsBase).Locale); if (PurchasingLimitProvider.RequirePurchasingLimits(DistributorID, CountryCode)) { if (order.PurchasingLimits == null) { var limits = PurchasingLimitProvider.GetCurrentPurchasingLimits(DistributorID); if (null != limits) { limits.PurchaseSubType = ShoppingCart.SelectedDSSubType; order.PurchasingLimits = limits; order.PurchaseCategory = limits.PurchaseType; } } } order = OrderProvider.PopulateLineItems(CountryCode, order, ShoppingCart) as Order_V01; order.DiscountPercentage = (ShoppingCart.Totals as OrderTotals_V01).DiscountPercentage; var theOrder = OrderProvider.CreateOrder(order, ShoppingCart, CountryCode); List <FailedCardInfo> failedCards = null; string error = string.Empty; string orderID = OrderProvider.ImportOrder(theOrder, out error, out failedCards, ShoppingCart.ShoppingCartID); if (string.IsNullOrEmpty(error)) { // TODO: how to get auth token ShoppingCartProvider.UpdateShoppingCart(ShoppingCart, OrderProvider.SerializeOrder(theOrder, order, ShoppingCart, new Guid()), orderID, order.ReceivedDate); if (string.IsNullOrEmpty(order.OrderID)) { order.OrderID = orderID; order.Pricing = ShoppingCart.Totals; } if (!String.IsNullOrEmpty(ShoppingCart.EmailAddress)) { EmailHelper.SendEmail(ShoppingCart, order); } OrderSubmitted(order, orderID); // Handling UI lbOrderNumValue.Text = orderID; divPayment.Attributes.Add("class", string.Format("{0} hide", divSubmitCommand.Attributes["class"])); divPaymentSummary.Attributes["class"] = divEmailNotification.Attributes["class"].Replace("hide", string.Empty); //hide the PaymentSummary if the Payment choice for HFF Order is Wire if (SessionInfo.SelectedPaymentChoice == "WireTransfer") { divPaymentSummary.Attributes["class"] = "hide"; } else { divPaymentSummary.Attributes["class"] = divEmailNotification.Attributes["class"].Replace("hide", string.Empty); } divOrderComplete.Attributes["class"] = divOrderComplete.Attributes["class"].Replace("hide", string .Empty); divEmailNotification.Attributes["class"] = divEmailNotification.Attributes["class"].Replace("hide", string.Empty); divSubmitCommand.Attributes.Add("class", string.Format("{0} hide", divSubmitCommand.Attributes["class"])); divEndCommand.Attributes["class"] = divEndCommand.Attributes["class"].Replace("hide", string.Empty); if (PurchasingLimitProvider.RequirePurchasingLimits(DistributorID, CountryCode)) { PurchasingLimitProvider.ReconcileAfterPurchase(ShoppingCart, DistributorID, CountryCode); } var currentSession = SessionInfo.GetSessionInfo(DistributorID, Locale); if (currentSession != null) { if (!String.IsNullOrEmpty(currentSession.OrderNumber)) { currentSession.OrderNumber = String.Empty; currentSession.OrderMonthShortString = string.Empty; currentSession.OrderMonthString = string.Empty; currentSession.ShippingMethodNameMX = String.Empty; currentSession.ShippingMethodNameUSCA = String.Empty; currentSession.ShoppingCart.CustomerOrderDetail = null; // currentSession.CustomerPaymentSettlementApproved = false; Commented out for Merge. Need to investigate currentSession.CustomerOrderNumber = String.Empty; currentSession.CustomerAddressID = 0; if (null != currentSession.ShippingAddresses) { var customerAddress = currentSession.ShippingAddresses.Find( p => p.ID == currentSession.CustomerAddressID); if (customerAddress != null) { currentSession.ShippingAddresses.Remove(customerAddress); } } } } //Clear the order month session... Session["OrderMonthDataSessionKey"] = null; SessionInfo.SetSessionInfo(DistributorID, Locale, currentSession); if (ShoppingCart != null) { // take out quantities from inventory ShoppingCartProvider.UpdateInventory(ShoppingCart, CountryCode, Locale, true); } ShoppingCart.CloseCart(); RecoverActiveCart(); onHFFOrderPlaced(this, new EventArgs()); } else { LoggerHelper.Error(error); if (error.Contains("AUTHORIZE PAYMENT")) { _errors.Add(PlatformResources.GetGlobalResourceString("ErrorMessage", "PaymenyFail")); } else if (error.Contains("TIMEOUT")) { _errors.Add(PlatformResources.GetGlobalResourceString("ErrorMessage", "Resubmit")); } else if (error.Contains("ORDER CANNOT BE FULFILLED FOR THE DISTRIBUTOR")) { _errors.Add(PlatformResources.GetGlobalResourceString("ErrorMessage", "CantOrder")); } else { _errors.Add(PlatformResources.GetGlobalResourceString("ErrorMessage", "TransactionFail")); } } } } } }
public object CreateOrder(Order_V01 order, MyHLShoppingCart shoppingCart, string countryCode, ThreeDSecuredCreditCard threeDSecuredCreditCard, string source = null) { return(OrderProvider.CreateOrder(order, shoppingCart, countryCode, threeDSecuredCreditCard, source)); }
public MyHerbalife3.Ordering.ServiceProvider.OrderSvc.OnlineOrder CreateOrder(string orderNumber, MyHLShoppingCart shoppingCart, PaymentCollection payments) { return(OrderProvider.CreateOrder(orderNumber, shoppingCart, payments)); }
public object CreateOrder(Order_V01 order, MyHLShoppingCart shoppingCart, string countryCode) { return(OrderProvider.CreateOrder(order, shoppingCart, countryCode)); }