public static List <BankInformation> GetAvailableBanks(BankUsage usage = BankUsage.UsedByGateway) { string cacheKey = BANKINFO_CACHE_PREFIX + usage.ToString(); var bankList = HttpRuntime.Cache[cacheKey] as List <BankInformation>; if (null == bankList) { using (var orderProxy = ServiceClientProvider.GetChinaOrderServiceProxy()) { try { var response = orderProxy.GetBankInfo(new GetBankInfoRequest1(new GetBankInfoRequest_V01() { Usage = usage })).GetBankInfoResult as GetBankInfoResponse_V01; if (response != null && response.Status == ServiceResponseStatusType.Success) { bankList = response.Banks.ToList(); HttpRuntime.Cache.Insert(cacheKey, bankList, null, DateTime.Now.AddMinutes(BankInfoCacheMinutes), Cache.NoSlidingExpiration); } } catch (Exception ex) { WebUtilities.LogServiceExceptionWithContext <MyHerbalife3.Ordering.ServiceProvider.OrderChinaSvc.IChinaInterface>(ex, orderProxy); } } } return(bankList); }
public WechatPrepayIdResponseViewModel GetPrepayId(WechatPrepayIdViewModel request, string orderNumber, decimal amount) { if (null == request) { return(null); } if (string.IsNullOrEmpty(request.MemberId) || string.IsNullOrEmpty(request.Locale)) { return(null); } GetWechatPaymentPrepayIdResponse response = null; var totalFeeInCents = (int)(amount * 100); using (var proxy = ServiceClientProvider.GetChinaOrderServiceProxy()) { response = proxy.GetWechatPaymentPrepayId(new GetWechatPaymentPrepayIdRequest1(new GetWechatPaymentPrepayIdRequest_V01 { Body = request.Body, Ip = request.Ip, OrderNumber = orderNumber, TotalFee = totalFeeInCents, })).GetWechatPaymentPrepayIdResult; } if (null != response) { var responseV01 = response as GetWechatPaymentPrepayIdResponse_V01; if (null != responseV01 && responseV01.Status == ServiceResponseStatusType.Success) { return(new WechatPrepayIdResponseViewModel { OrderNumber = orderNumber, PrepayId = responseV01.PrepayId }); } } return(null); }
public bool QueryWechatOrder(string orderNumber) { GetWechatPaymentQueryOrderResponse response = null; using (var proxy = ServiceClientProvider.GetChinaOrderServiceProxy()) { response = proxy.GetWechatPaymentQueryOrder(new GetWechatPaymentQueryOrderRequest1(new GetWechatPaymentQueryOrderRequest_V01 { OrderNumber = orderNumber, })).GetWechatPaymentQueryOrderResult; } if (null != response) { var responseV01 = response as GetWechatPaymentQueryOrderResponse_V01; if (null != responseV01 && responseV01.Status == ServiceResponseStatusType.Success && responseV01.ReturnCode == "SUCCESS") { return("SUCCESS" == responseV01.TradeState); } } return(false); }
public FreightSimulationResult CalculateFreight(ServiceProvider.OrderChinaSvc.ShippingInfo_V01 shippingInfo, decimal weight) { var freightSimulationResult = new FreightSimulationResult(); if (shippingInfo == null || shippingInfo.Address == null || weight == 0) { return(freightSimulationResult); } if (Settings.GetRequiredAppSetting("LogShipping", "false").ToLower() == "true") { LogRequest(string.Format("ShippingInfo before CalculateFreight: {0}", OrderCreationHelper.Serialize(shippingInfo))); } if (!string.IsNullOrEmpty(shippingInfo.Address.StateProvinceTerritory) && !string.IsNullOrEmpty(shippingInfo.Address.City) && !string.IsNullOrEmpty(shippingInfo.Address.CountyDistrict)) { if (string.IsNullOrEmpty(shippingInfo.ShippingMethodID)) { var mappings = GetProvinceStoreMapping(); if (mappings != null) { var mapping = mappings.Find(m => m.ProvinceName == shippingInfo.Address.StateProvinceTerritory); if (mapping != null) { shippingInfo.ShippingMethodID = mapping.StoreID.ToString(); } } } if (string.IsNullOrEmpty(shippingInfo.WarehouseCode)) { shippingInfo.WarehouseCode = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultFreightCode; } var proxy = ServiceClientProvider.GetChinaOrderServiceProxy(); var result = proxy.GetFreightCharge(new ServiceProvider.OrderChinaSvc.GetFreightChargeRequest1(new ServiceProvider.OrderChinaSvc.GetFreightChargeRequest_V01() { ShippingInfo = shippingInfo, Weight = weight })).GetFreightChargeResult as ServiceProvider.OrderChinaSvc.GetFreightChargeResponse_V01; if (result != null && result.Status == ServiceProvider.OrderChinaSvc.ServiceResponseStatusType.Success) { freightSimulationResult.EstimatedFreight = result.Freight; freightSimulationResult.StoreName = result.StoreName; } } if (Settings.GetRequiredAppSetting("LogShipping", "false").ToLower() == "true") { LogRequest(string.Format("ShippingInfo after CalculateFreight: {0}", OrderCreationHelper.Serialize(shippingInfo))); } return(freightSimulationResult); }
public List<MyHLShoppingCartView> GetOrdersWithDetail(string distributorId, int customerProfileID, string countryCode, DateTime startOrderDate, DateTime endOrderDate, MyHerbalife3.Ordering.Providers.China.OrderStatusFilterType statusFilter, string filterExpressions, string sortExpressions, bool isNonGDOOrder = false, bool isPreOrdering = false, string orderNumber = null) { List<MyHLShoppingCartView> result; List<OnlineOrder> orderListing = null; List<OrderStatusType> ordStsList = new List<OrderStatusType>(); List<PaymentGatewayRecordStatusType> pgrStsList = new List<PaymentGatewayRecordStatusType>(); List<PaymentPendingOrderPaymentStatusType> ppoStsList = new List<PaymentPendingOrderPaymentStatusType>(); if (Settings.GetRequiredAppSetting("GetOrderinfoCache", "true") == "true") { result = SearchFromCachedList(distributorId, statusFilter, filterExpressions, sortExpressions, startOrderDate, endOrderDate, orderNumber); if (result != null) { return result; } } result = new List<MyHLShoppingCartView>(); switch (statusFilter) { case OrderStatusFilterType.Cancel_Order: ordStsList.Add(OrderStatusType.Cancel_Order); break; case OrderStatusFilterType.Complete: ordStsList.Add(OrderStatusType.Complete); break; case OrderStatusFilterType.In_Progress: ordStsList.Add(OrderStatusType.In_Progress); break; case OrderStatusFilterType.NTS_Printed: ordStsList.Add(OrderStatusType.NTS_Printed); break; case OrderStatusFilterType.To_Be_Assign: ordStsList.Add(OrderStatusType.To_Be_Assign); break; case OrderStatusFilterType.Payment_Failed: case OrderStatusFilterType.Payment_Pending: ordStsList = null; break; } switch (statusFilter) { case OrderStatusFilterType.Payment_Pending: pgrStsList.Add(PaymentGatewayRecordStatusType.Unknown); break; case OrderStatusFilterType.Cancel_Order: pgrStsList.Add(PaymentGatewayRecordStatusType.CancelledByUser); break; case OrderStatusFilterType.Payment_Failed: pgrStsList.Add(PaymentGatewayRecordStatusType.Declined); break; case OrderStatusFilterType.All: pgrStsList.Add(PaymentGatewayRecordStatusType.Unknown); pgrStsList.Add(PaymentGatewayRecordStatusType.CancelledByUser); pgrStsList.Add(PaymentGatewayRecordStatusType.Declined); break; } switch (statusFilter) { case OrderStatusFilterType.Cancel_Order: ppoStsList.Add(PaymentPendingOrderPaymentStatusType.CNCancelled); break; case OrderStatusFilterType.Payment_Pending: ppoStsList.Add(PaymentPendingOrderPaymentStatusType.CNPending); break; case OrderStatusFilterType.All: ppoStsList.Add(PaymentPendingOrderPaymentStatusType.CNCancelled); ppoStsList.Add(PaymentPendingOrderPaymentStatusType.CNPending); break; } var req = new GetOrdersRequest_V02 { CountryCode = countryCode, CustomerProfileID = customerProfileID, OrderFilter = new OrdersFilter { DistributorId = distributorId, StartDate = startOrderDate, EndDate = endOrderDate, OrderStatusList = ordStsList, IsNonGDOOrders = isNonGDOOrder, OrderNumber = orderNumber, }, OrderingType = isPreOrdering ? OrderingType.PreOrder : OrderingType.RSO, PaymentGatewayRecordStatusList = pgrStsList, PaymentPendingOrderPaymentStatusList = ppoStsList, }; if (_chinaOrderProxy == null) _chinaOrderProxy = ServiceClientProvider.GetChinaOrderServiceProxy(); var rsp = _chinaOrderProxy.GetOrdersWithDetail(new GetOrdersWithDetailRequest(req)).GetOrdersWithDetailResult as GetOrdersResponse_V01; if (Helper.Instance.ValidateResponse(rsp)) { orderListing = rsp.Orders; } else LoggerHelper.Error(string.Format("MyHLShoppingCartView.GetOrdersWithDetail() Error. Unsuccessful result from web service ChinaOrderSVC.GetOrdersWithDetail. Data: DistributorId={0}", distributorId)); bool copyEnabled = true; bool hasUnknownOrder = false; bool pendingPayment = false; List<MyHLProductItemView> cartItems; if (Helper.Instance.HasData(orderListing)) { var unknownOrder = (from a in orderListing where a.Status == "未知" select a).FirstOrDefault(); //dont display feedback, if any order is pending if (unknownOrder != null) { hasUnknownOrder = true; } var virtualProduct = GetVirtualProduct(); foreach (var order in orderListing) { var priceInfo = order.Pricing as OrderTotals_V01; var priceInfo_V02 = order.Pricing as OrderTotals_V02; if (priceInfo == null) continue; switch (order.Status) { case "未知": //unknown order copyEnabled = false; pendingPayment = true; break; default: pendingPayment = false; copyEnabled = !hasUnknownOrder; break; } var orderView = new MyHLShoppingCartView { ID = order.ShoppingCartID.ToString(), OrderNumber = order.OrderID ?? string.Empty, Date = order.ReceivedDate.ToString("d", CultureInfo.CurrentCulture), DateTimeForOrder = order.ReceivedDate, VolumePoints = priceInfo.VolumePoints.ToString("00.00"), TotalAmountValue = priceInfo.AmountDue, VolumePointsValue = priceInfo.VolumePoints, ProductTaxTotal = priceInfo_V02 != null ? priceInfo_V02.ProductTaxTotal : decimal.Zero, DonationAmount = priceInfo_V02 != null ? priceInfo_V02.Donation : decimal.Zero, SelfDonationAmount = priceInfo_V02 != null ? priceInfo_V02.SelfDonationAmount : decimal.Zero, OnBehalfDonationAmount = priceInfo_V02 != null ? priceInfo_V02.OnBehalfDonationAmount : decimal.Zero, OnBehalfDonationContact = priceInfo_V02 != null ? priceInfo_V02.OnBehalfDonationContact : string.Empty, SelfDonationMemberId = priceInfo_V02 != null ? priceInfo_V02.SelfDonationMemberId : string.Empty, OnBehalfDonationName = priceInfo_V02 != null ? priceInfo_V02.OnBehalfDonationName : string.Empty, DiscountAmount = priceInfo_V02 != null ? priceInfo_V02.DiscountAmount : decimal.Zero, FreightCharges = priceInfo_V02 != null && null != priceInfo_V02.ChargeList && priceInfo_V02.ChargeList.Any() ? GetFreightCharges(priceInfo_V02.ChargeList) : decimal.Zero, OrderStatus = order.Status, StoreInfo = order.StoreInfo, WarehouseCode = ((order.Shipment as ShippingInfo_V01) == null) ? "" : (order.Shipment as ShippingInfo_V01).WarehouseCode, ChannelInfo = order.ChannelInfo, OrderMonth = order.OrderMonth, IsCopyEnabled = order.ShoppingCartID > 0 ? copyEnabled : false, //If ShoppingCartID is 0 then CopyEnabled is set to false OrderHeaderId = order.OrderHeaderID, DistributorID = distributorId, HasFeedBack = (order.HasFeedBack && !hasUnknownOrder), CreatedBy = order.CreatedBy, IsPaymentPending = pendingPayment, }; var shippingAddress = order.Shipment as ShippingInfo_V01; if (shippingAddress != null) { if (shippingAddress.Address != null) orderView.Address = shippingAddress.Address.StateProvinceTerritory + shippingAddress.Address.CountyDistrict + shippingAddress.Address.City + shippingAddress.Address.Line1 + shippingAddress.Address.PostalCode; orderView.AddressValue = ObjectMappingHelper.Instance.GetToShipping(shippingAddress.Address); orderView.Recipient = shippingAddress.Recipient; orderView.Phone = shippingAddress.Phone; orderView.ShippingMethodId = shippingAddress.ShippingMethodID; } orderView.TotalAmount = (priceInfo.AmountDue + orderView.FreightCharges).ToString("00"); var createdBy = order.CreatedBy; if (!string.IsNullOrWhiteSpace(createdBy)) orderView.IsHistoricalData = (createdBy.Trim().ToUpper() != "GDO"); cartItems = new List<MyHLProductItemView>(); if (order.OrderItems != null && order.OrderItems.Count > 0) { foreach (var itm in order.OrderItems) { if (string.IsNullOrEmpty(itm.SKU)) continue; if (itm.SKU.EndsWith("||")) { itm.SKU = itm.SKU.Replace("||", ""); //a workaround to indicate this is preordering. orderView.IsCopyEnabled = false; } if (itm is OnlineOrderItem) { var orderItem = itm as OnlineOrderItem; if (orderItem != null) { cartItems.Add(new MyHLProductItemView() { Quantity = orderItem.Quantity, SKU = string.IsNullOrEmpty(orderItem.SKU) ? "" : orderItem.SKU.Trim(), Description = orderItem.Description, RetailPrice = orderItem.RetailPrice }); } } else if (itm is OrderItem_V02) { var orderItem = itm as OrderItem_V02; if (orderItem != null) { cartItems.Add(new MyHLProductItemView() { Quantity = orderItem.Quantity, SKU = string.IsNullOrEmpty(orderItem.SKU) ? "" : orderItem.SKU.Trim(), Description = orderItem.Description, RetailPrice = orderItem.RetailPrice }); } } } } orderView.CartItems = cartItems; if (IsChina) { var isAllVirtualOrder = IsAllVirtualOrder(orderView, virtualProduct); orderView.IsCopyEnabled = isAllVirtualOrder ? false : orderView.IsCopyEnabled; if (isAllVirtualOrder) { orderView.HasFeedBack = true; //Set this true so that the feedback button will not showing. } } result.Add(orderView); } } // Search if (!string.IsNullOrWhiteSpace(filterExpressions)) result = Search(result, filterExpressions); // Order Number if (!string.IsNullOrWhiteSpace(orderNumber)) result = Search(result, orderNumber); // Sort if (string.IsNullOrWhiteSpace(sortExpressions)) result = result.OrderByDescending(item => item.DateTimeForOrder).ToList(); else result = ChinaDoSortBy(result, sortExpressions); if (Settings.GetRequiredAppSetting("GetOrderinfoCache", "true") == "true") { string cacheKey = string.Format(OrderListCaheKey + distributorId + "CN" + statusFilter + filterExpressions + sortExpressions + startOrderDate.ToString(YearMonthDayFormat) + endOrderDate.ToString(YearMonthDayFormat) + orderNumber); HttpRuntime.Cache.Insert(cacheKey, result, null, DateTime.Now.AddMinutes(Convert.ToDouble(Settings.GetRequiredAppSetting("GetOrderinfoCacheTimeout"))), Cache.NoSlidingExpiration, CacheItemPriority.Low, null); } return result; }
public List<MyHLShoppingCartView> GetPreOrders(string distributorId, int customerProfileID, string countryCode, DateTime? startOrderDate, DateTime? endOrderDate, MyHerbalife3.Ordering.Providers.China.PreOrderStatusFilterType statusFilter, string filterExpressions, string sortExpressions) { List<MyHLShoppingCartView> ret = new List<MyHLShoppingCartView>(); #region date range... bool isStartDateDefined = (startOrderDate != null); bool isEndDateDefined = (endOrderDate != null); var sDate = !isStartDateDefined ? DateTime.Now.AddMonths(-1) : startOrderDate.Value; var eDate = !isEndDateDefined ? DateTime.Now.AddDays(2) : endOrderDate.Value; // if only one of them is undefined... adjust the other accordingly if ((!isStartDateDefined || !isEndDateDefined) && (isStartDateDefined != isEndDateDefined)) { if (!isStartDateDefined) sDate = eDate.AddMonths(-1); if (!isEndDateDefined) eDate = sDate.AddMonths(1); } #endregion List<OnlineOrder> orderHeaderList = null; #region OrderHeader List<PreOrderImportStatusType> ordStsList = new List<PreOrderImportStatusType>(); #region OrderStatusList switch (statusFilter) { case PreOrderStatusFilterType.Cancel_PreOrder: ordStsList.Add(PreOrderImportStatusType.Cancel); break; case PreOrderStatusFilterType.Hold_PreOrder: ordStsList.Add(PreOrderImportStatusType.Hold); break; case PreOrderStatusFilterType.ReadyToSubmit_PreOrder: ordStsList.Add(PreOrderImportStatusType.ReadyToSubmit); break; } #endregion if (ordStsList != null) // ordStsList.Count == 0 means all, so need to query { var req = new GetPreOrdersRequest_V01 { CustomerProfileID = customerProfileID, OrderFilter = new PreOrdersFilter { DistributorId = distributorId, StartDate = sDate, EndDate = eDate, OrderStatusList = ordStsList }, }; if (_chinaOrderProxy == null) _chinaOrderProxy = ServiceClientProvider.GetChinaOrderServiceProxy(); var rsp = _chinaOrderProxy.GetPreOrders(new GetPreOrdersRequest1(req)).GetPreOrdersResult as GetPreOrdersResponse_V01; if (Helper.Instance.ValidateResponse(rsp)) { if (!IsChina) orderHeaderList = rsp.Orders.Where(h => h.OrderCategory == OrderCategoryType.RSO).ToList(); else orderHeaderList = rsp.Orders; } else LoggerHelper.Error(string.Format("MyHLShoppingCartView.GetPreOrders() Error. Unsuccessful result from web service ChinaOrderSVC.GetPreOrders. Data: DistributorId={0}", distributorId)); } #endregion #region orderHeaderList if (Helper.Instance.HasData(orderHeaderList)) { foreach (var order in orderHeaderList) { var priceInfo = order.Pricing as OrderTotals_V01; var priceInfo_V02 = order.Pricing as OrderTotals_V02; if (priceInfo == null) continue; if (priceInfo.ItemsTotal <= 0) continue; var orderView = new MyHLShoppingCartView { ID = order.ShoppingCartID.ToString(), OrderNumber = order.OrderID ?? string.Empty, Date = order.ReceivedDate.AddHours(8).ToString("d", CultureInfo.CurrentCulture), DateTimeForOrder = order.ReceivedDate.AddHours(8), TotalAmount = priceInfo.AmountDue.ToString("##.##"), VolumePoints = priceInfo.VolumePoints.ToString("00.00"), TotalAmountValue = priceInfo.AmountDue, VolumePointsValue = priceInfo.VolumePoints, ProductTaxTotal = priceInfo_V02 != null ? priceInfo_V02.ProductTaxTotal : decimal.Zero, DonationAmount = priceInfo_V02 != null ? priceInfo_V02.Donation : decimal.Zero, DiscountAmount = priceInfo_V02 != null ? priceInfo_V02.DiscountAmount : decimal.Zero, FreightCharges = priceInfo_V02 != null && null != priceInfo_V02.ChargeList && priceInfo_V02.ChargeList.Any() ? GetFreightCharges(priceInfo_V02.ChargeList) : decimal.Zero, OrderStatus = order.Status, StoreInfo = order.StoreInfo, ChannelInfo = order.ChannelInfo, OrderMonth = order.OrderMonth, OrderHeaderId = order.OrderHeaderID, DistributorID = order.DistributorID, HasFeedBack = order.HasFeedBack, CreatedBy = order.CreatedBy, }; orderView.TotalAmount = (priceInfo.AmountDue + orderView.FreightCharges).ToString("00"); LoadPreOrderDetails(orderView); orderView.Address = ((ShippingInfo_V01)order.Shipment).Address.StateProvinceTerritory + ((ShippingInfo_V01)order.Shipment).Address.CountyDistrict + ((ShippingInfo_V01)order.Shipment).Address.City + ((ShippingInfo_V01)order.Shipment).Address.Line1 + ((ShippingInfo_V01)order.Shipment).Address.PostalCode; orderView.AddressValue = ObjectMappingHelper.Instance.GetToShipping(((ShippingInfo_V01)order.Shipment).Address); orderView.Recipient = ((ShippingInfo_V01)order.Shipment).Recipient; orderView.Phone = ((ShippingInfo_V01)order.Shipment).Phone; orderView.WarehouseCode = ((ShippingInfo_V01)order.Shipment).WarehouseCode; orderView.ShippingMethodId = ((ShippingInfo_V01)order.Shipment).ShippingMethodID; var createdBy = order.CreatedBy; if (!string.IsNullOrWhiteSpace(createdBy)) orderView.IsHistoricalData = (createdBy.Trim().ToUpper() != "GDO"); ret.Add(orderView); } } #endregion // Search if (!string.IsNullOrWhiteSpace(filterExpressions)) ret = Search(ret, filterExpressions); // Sort if (string.IsNullOrWhiteSpace(sortExpressions)) ret = ret.OrderByDescending(item => item.OrderNumber).ToList(); else ret = ChinaDoSortBy(ret, sortExpressions); return ret; }
public static bool PostCNPForMobile(MyHLShoppingCart shoppingcart, CreditPayment_V01 payment, string disId, string name, decimal amoun, string orderNumber, string distributorId, string phone) { if (shoppingcart == null || payment == null) { return(false); } ConfigHelper configHelper = new ConfigHelper("CN_99BillPaymentGateway"); var tr3Url = configHelper.GetConfigEntry("paymentGatewayReturnUrlApproved"); var merchantId = configHelper.GetConfigEntry("CNPTerminalId"); var terminalId = configHelper.GetConfigEntry("terminalId"); try { var amount = amoun <= 0 ? "0.00" : amoun.ToString("0.00"); var tins = DistributorOrderingProfileProvider.GetTinList(disId, true); var tin = tins.Find(t => t.ID == "CNID"); var sbXml = new StringBuilder(); sbXml.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><MasMessage xmlns=\"http://www.99bill.com/mas_cnp_merchant_interface\">"); sbXml.Append("<version>1.0</version><TxnMsgContent><txnType>PUR</txnType><interactiveStatus>TR1</interactiveStatus>"); sbXml.AppendFormat("<cardNo>{0}</cardNo>", payment.Card.AccountNumber); sbXml.AppendFormat("<expiredDate>{0}</expiredDate>", payment.Card.Expiration.ToString("MM") + payment.Card.Expiration.ToString("yy")); sbXml.AppendFormat("<cvv2>{0}</cvv2>", payment.Card.CVV); sbXml.AppendFormat("<amount>{0}</amount>", amount); sbXml.AppendFormat("<merchantId>{0}</merchantId>", merchantId.Trim()); sbXml.AppendFormat("<terminalId>{0}</terminalId>", terminalId.Trim()); sbXml.AppendFormat("<cardHolderName>{0}</cardHolderName>", name); sbXml.AppendFormat("<cardHolderId>{0}</cardHolderId>", tin == null ? string.Empty : tin.IDType.Key.Trim()); sbXml.Append("<idType>0</idType>"); sbXml.AppendFormat("<entryTime>{0}</entryTime>", DateTime.Now.ToString("yyyyMMddHHmmss")); sbXml.AppendFormat("<externalRefNumber>{0}</externalRefNumber>", orderNumber); sbXml.AppendFormat("<extMap><extDate><key>phone</key><value>{0}</value></extDate></extMap>", phone); sbXml.AppendFormat("<tr3Url>{0}</tr3Url>", tr3Url.Trim()); sbXml.AppendFormat("<bankId>{0}</bankId>", payment.AuthorizationMerchantAccount); sbXml.AppendFormat("</TxnMsgContent></MasMessage>"); var encyptedCardNum = CryptographicProvider.Encrypt(payment.Card.AccountNumber); var encryptedCvv = CryptographicProvider.Encrypt(payment.Card.CVV); var decyptedCardNum = CryptographicProvider.Decrypt(encyptedCardNum); var decryptedCvv = CryptographicProvider.Decrypt(encryptedCvv); var logData = sbXml.ToString() .Replace(payment.Card.AccountNumber, encyptedCardNum) .Replace(payment.Card.CVV, encryptedCvv); LogMessageWithInfo(PaymentGatewayLogEntryType.Request, orderNumber, orderNumber, orderNumber, PaymentGatewayRecordStatusType.Unknown, logData); bool isLockedeach = true; bool isLocked = true; string lockfailed = string.Empty; if (shoppingcart.pcLearningPointOffSet > 0M && !(shoppingcart.OrderCategory == ServiceProvider.CatalogSvc.OrderCategoryType.ETO)) { isLockedeach = OrderProvider.LockPCLearningPoint(distributorId, orderNumber, new OrderMonth(shoppingcart.CountryCode).OrderMonthShortString, Convert.ToInt32(Math.Truncate(shoppingcart.pcLearningPointOffSet)), HLConfigManager.Platform); if (!isLockedeach) { lockfailed = "PC Learning Point"; isLocked = false; } } else if (shoppingcart.pcLearningPointOffSet > 0M) { isLockedeach = OrderProvider.LockETOLearningPoint( shoppingcart.CartItems.Select(s => s.SKU), distributorId, orderNumber, new OrderMonth(shoppingcart.CountryCode).OrderMonthShortString, Convert.ToInt32(Math.Truncate(shoppingcart.pcLearningPointOffSet)), HLConfigManager.Platform); if (!isLockedeach) { lockfailed = "ETO Learning Point"; isLocked = false; } } if (shoppingcart.HastakenSrPromotion) { isLockedeach = ChinaPromotionProvider.LockSRPromotion(shoppingcart, orderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", SR Promotion"; isLocked = false; } } if (shoppingcart.HastakenSrPromotionGrowing) { isLockedeach = ChinaPromotionProvider.LockSRQGrowingPromotion(shoppingcart, orderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", SR Query Growing"; isLocked = false; } } if (shoppingcart.HastakenSrPromotionExcelnt) { isLockedeach = ChinaPromotionProvider.LockSRQExcellentPromotion(shoppingcart, orderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", SR Query Excellent"; isLocked = false; } } if (shoppingcart.HastakenBadgePromotion) { isLockedeach = ChinaPromotionProvider.LockBadgePromotion(shoppingcart, orderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", Badge promo"; isLocked = false; } } if (shoppingcart.HastakenNewSrpromotion) { isLockedeach = ChinaPromotionProvider.LockNewSRPromotion(shoppingcart, orderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", NewSrPromotion"; isLocked = false; } } if (shoppingcart.HasBrochurePromotion) { isLockedeach = ChinaPromotionProvider.LockBrochurePromotion(shoppingcart, orderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", Brochure Promotion"; isLocked = false; } } if (isLocked) { var proxy = ServiceClientProvider.GetChinaOrderServiceProxy(); var request = new ServiceProvider.OrderChinaSvc.GetCNPPaymentServiceRequest_V01() { Data = sbXml.ToString().Replace(payment.Card.AccountNumber, payment.Card.AccountNumber) }; var response = proxy.GetCnpPaymentServiceDetail(new ServiceProvider.OrderChinaSvc.GetCnpPaymentServiceDetailRequest(request)).GetCnpPaymentServiceDetailResult as ServiceProvider.OrderChinaSvc.GetCNPPaymentServiceResponse_V01; if (null != response) { if (response.Status == ServiceProvider.OrderChinaSvc.ServiceResponseStatusType.Success && response.Response.Length > 0) { var msgReturn = response.Response; if (msgReturn.IndexOf("xmlns=\"http://www.99bill.com/mas_cnp_merchant_interface\"") > 1) { msgReturn = msgReturn.Replace(" xmlns=\"http://www.99bill.com/mas_cnp_merchant_interface\"", ""); } var xmlDoc = new XmlDocument(); var encodedString = Encoding.UTF8.GetBytes(msgReturn); var ms = new MemoryStream(encodedString); ms.Flush(); ms.Position = 0; // Build the XmlDocument from the MemorySteam of UTF-8 encoded bytes xmlDoc.Load(ms); var list = xmlDoc.SelectNodes("//TxnMsgContent"); var externalRefNumberback = string.Empty; var refNumberback = string.Empty; var gatewayAmount = string.Empty; var approved = false; if (list != null && list.Count == 0) { var selectSingleNode = xmlDoc.SelectSingleNode("MasMessage/ErrorMsgContent/errorMessage"); if (selectSingleNode != null) { var errorMessage = selectSingleNode.InnerText; LogMessageWithInfo(PaymentGatewayLogEntryType.Response, orderNumber, distributorId, "CN_99BillPaymentGatewayInvoker", PaymentGatewayRecordStatusType.Declined, msgReturn + errorMessage); return(false); } } else { var authorizationCodeback = ""; var selectSingleNode = xmlDoc.SelectSingleNode("MasMessage/TxnMsgContent/responseCode"); if (selectSingleNode != null) { var responseCode = selectSingleNode.InnerText; approved = responseCode == "00"; if (!approved) { var strCNPUnknown = Settings.GetRequiredAppSetting("CNPResponseCodeForUnknown", "C0,68"); var cnpResponseCodeForUnknown = new List <string>(strCNPUnknown.Split(new char[] { ',' })); if (cnpResponseCodeForUnknown.Contains(responseCode.ToUpper())) { return(approved); } LogMessageWithInfo(PaymentGatewayLogEntryType.Response, orderNumber, string.Empty, "CN_99BillPaymentGateway", PaymentGatewayRecordStatusType.Declined, msgReturn); return(approved); } } var singleNode = xmlDoc.SelectSingleNode("MasMessage/TxnMsgContent/externalRefNumber"); externalRefNumberback = singleNode != null ? singleNode.InnerText : string.Empty; var refNumber = xmlDoc.SelectSingleNode("MasMessage/TxnMsgContent/refNumber"); refNumberback = refNumber != null ? refNumber.InnerText : string.Empty; var authorizationCode = xmlDoc.SelectSingleNode("MasMessage/TxnMsgContent/authorizationCode"); authorizationCodeback = authorizationCode != null ? authorizationCode.InnerText : string.Empty; var retAmount = xmlDoc.SelectSingleNode("MasMessage/TxnMsgContent/amount"); gatewayAmount = retAmount != null ? retAmount.InnerText : string.Empty; LogMessageWithInfo(PaymentGatewayLogEntryType.Response, orderNumber, distributorId, "CN_99BillPaymentGatewayInvoker", PaymentGatewayRecordStatusType.Approved, msgReturn); //sessionInfo.OrderStatus = SubmitOrderStatus.Unknown; } payment.Card.IssuingBankID = refNumberback; payment.AuthorizationMerchantAccount = externalRefNumberback; return(approved); } else { var resp = string.Format( "Response failure. Unable to connect to 99Bill. OrderNumber: {0} ; response: {1}; status: {2}", orderNumber, response.Response, response.Status); //LoggerHelper.Error(resp); LogMessageWithInfo(PaymentGatewayLogEntryType.Response, orderNumber, distributorId, "CN_99BillPaymentGatewayInvoker", PaymentGatewayRecordStatusType.Declined, resp); return(false); } } else { var resp = "Response null, Unable to connect to 99Bill. OrderNumber:" + orderNumber; //LoggerHelper.Error(resp); LogMessageWithInfo(PaymentGatewayLogEntryType.Response, orderNumber, distributorId, "CN_99BillPaymentGatewayInvoker", PaymentGatewayRecordStatusType.Declined, resp); return(false); } } else { var resp = "PostCNP - " + lockfailed.TrimStart(',') + " locking fails. OrderNumber:" + orderNumber; LogMessageWithInfo(PaymentGatewayLogEntryType.Response, orderNumber, distributorId, "CN_99BillPaymentGatewayInvoker", PaymentGatewayRecordStatusType.Declined, resp); return(false); } } catch (Exception ex) { var resp = string.Format("PostCNP Error. OrderNumber: {0}. ex : {1} ", orderNumber, ex.Message); LoggerHelper.Error(resp); LogMessage(PaymentGatewayLogEntryType.Response, orderNumber, distributorId, "CN_99BillPaymentGatewayInvoker", PaymentGatewayRecordStatusType.Declined, resp); return(false); } }