/// <summary> /// /// </summary> public override void Submit() { if (this._theInvoker != null) { this._theInvoker.Submit(); return; } var redirectUrl = _configHelper.GetConfigEntry("paymentGatewayUrl"); var orderNumber = _orderNumber; var returnURL = _configHelper.GetConfigEntry("paymentGatewayReturnUrlApproved"); var amount = _orderAmount <= 0 ? "0.00" : (Convert.ToDouble(_orderAmount.ToString("0.00")) * 100).ToString(); var returnUrl = string.Concat(RootUrl, returnURL); var paymentGatewayReturnBgUrl = _configHelper.GetConfigEntry("paymentGatewayReturnBgUrl"); var bgrUrl = string.Concat(RootUrl, paymentGatewayReturnBgUrl + "?rtnOrderNumber=" + orderNumber); var merchantId = _configHelper.GetConfigEntry("paymentGatewayMerchantdId"); var disId = _distributorId; var membershipUser = (MembershipUser <DistributorProfileModel>)Membership.GetUser(); var name = string.Empty; if (membershipUser != null) { name = membershipUser.Value.DistributorName(); disId = membershipUser.Value.Id; } var sessionInfoMyCart = SessionInfo.GetSessionInfo(disId, _locale); sessionInfoMyCart.OrderStatus = SubmitOrderStatus.Unknown; var myCart = sessionInfoMyCart.ShoppingCart ?? ShoppingCartProvider.GetShoppingCart(disId, _locale); var email = string.Empty; var payerName = string.Empty; if (myCart != null) { email = (!string.IsNullOrEmpty(myCart.EmailAddress)) ? myCart.EmailAddress : string.Empty; payerName = (myCart.DeliveryInfo != null && myCart.DeliveryInfo.Address != null) ? myCart.DeliveryInfo.Address.Recipient ?? string.Empty : string.Empty; } var payment = HttpContext.Current.Session[PaymentInformation] as CreditPayment_V01; if (payment != null && payment.TransactionType == "CC") { PostCNP(myCart, payment, sessionInfoMyCart, disId, name); return; } if (payment != null) { if (payment.TransactionType == "10") { bgrUrl = bgrUrl + "&BankId=" + payment.AuthorizationMerchantAccount; } if (payment.TransactionType == "12") { bgrUrl = bgrUrl + "&BankId=Fastmoney"; } } string orderTime = DateTime.Now.ToString(DateTimeFormat); var signMsgVal = ""; signMsgVal = AppendParam(signMsgVal, "inputCharset", "1"); signMsgVal = AppendParam(signMsgVal, "pageUrl", returnUrl); signMsgVal = AppendParam(signMsgVal, "bgUrl", bgrUrl); signMsgVal = AppendParam(signMsgVal, "version", "v2.0"); signMsgVal = AppendParam(signMsgVal, "language", "1"); signMsgVal = AppendParam(signMsgVal, "signType", "4"); //4 = PKI signate signMsgVal = AppendParam(signMsgVal, "merchantAcctId", merchantId); signMsgVal = AppendParam(signMsgVal, "payerName", payerName); //????? signMsgVal = AppendParam(signMsgVal, "payerContactType", "1"); signMsgVal = AppendParam(signMsgVal, "payerContact", email); signMsgVal = AppendParam(signMsgVal, "orderId", orderNumber); signMsgVal = AppendParam(signMsgVal, "orderAmount", amount); signMsgVal = AppendParam(signMsgVal, "orderTime", orderTime); signMsgVal = AppendParam(signMsgVal, "productName", ProductName); signMsgVal = AppendParam(signMsgVal, "productNum", "1"); signMsgVal = AppendParam(signMsgVal, "productId", ""); signMsgVal = AppendParam(signMsgVal, "productDesc", ProductDesc); signMsgVal = AppendParam(signMsgVal, "ext1", ""); signMsgVal = AppendParam(signMsgVal, "ext2", ""); signMsgVal = AppendParam(signMsgVal, "payType", payment != null ? payment.TransactionType : "10"); if (payment.TransactionType == "10") // eBanking { signMsgVal = AppendParam(signMsgVal, "bankId", payment != null ? payment.AuthorizationMerchantAccount : string.Empty); } signMsgVal = AppendParam(signMsgVal, "redoFlag", "0"); signMsgVal = AppendParam(signMsgVal, "pid", ""); var signMsg = GenerateHash(signMsgVal); var sb = new StringBuilder(); sb.Append("<html>"); sb.AppendFormat(@"<body onload='document.forms[""form""].submit()'>"); sb.AppendFormat("<form name='form' action='{0}' method='post'>", redirectUrl); sb.AppendFormat(BuildHtml("inputCharset", "1")); sb.AppendFormat(BuildHtml("pageUrl", returnUrl)); sb.AppendFormat(BuildHtml("bgUrl", bgrUrl)); sb.AppendFormat(BuildHtml("version", "v2.0")); sb.AppendFormat(BuildHtml("language", "1")); sb.AppendFormat(BuildHtml("signType", "4")); sb.AppendFormat(BuildHtml("merchantAcctId", merchantId)); sb.AppendFormat(BuildHtml("payerName", payerName)); sb.AppendFormat(BuildHtml("payerContactType", "1")); sb.AppendFormat(BuildHtml("payerContact", email)); sb.AppendFormat(BuildHtml("orderId", orderNumber)); sb.AppendFormat(BuildHtml("orderAmount", amount)); sb.AppendFormat(BuildHtml("orderTime", orderTime)); sb.AppendFormat(BuildHtml("productName", ProductName)); sb.AppendFormat(BuildHtml("productNum", "1")); sb.AppendFormat(BuildHtml("productId", "")); sb.AppendFormat(BuildHtml("productDesc", ProductDesc)); sb.AppendFormat(BuildHtml("ext1", "")); sb.AppendFormat(BuildHtml("ext2", "")); sb.AppendFormat(BuildHtml("payType", payment != null ? payment.TransactionType : "10")); if (payment.TransactionType == "10") // eBanking { sb.AppendFormat(BuildHtml("bankId", payment != null ? payment.AuthorizationMerchantAccount : string.Empty)); } sb.AppendFormat(BuildHtml("redoFlag", "0")); sb.AppendFormat(BuildHtml("pid", "")); sb.AppendFormat(BuildHtml("signMsg", signMsg)); sb.Append("</form>"); sb.Append("</body>"); sb.Append("</html>"); var response = sb.ToString(); LogMessageWithInfo(PaymentGatewayLogEntryType.Request, OrderNumber, _distributorId, _gatewayName, PaymentGatewayRecordStatusType.Unknown, response); bool isLockedeach = true; bool isLocked = true; string lockfailed = string.Empty; if (myCart != null && myCart.pcLearningPointOffSet > 0M && !(myCart.OrderCategory == ServiceProvider.CatalogSvc.OrderCategoryType.ETO)) { isLockedeach = OrderProvider.LockPCLearningPoint(_distributorId, orderNumber, new OrderMonth(myCart.CountryCode).OrderMonthShortString, Convert.ToInt32(Math.Truncate(myCart.pcLearningPointOffSet)), HLConfigManager.Platform); if (!isLockedeach) { lockfailed = "PC Learning Point"; isLocked = false; } } else if (myCart != null && myCart.pcLearningPointOffSet > 0M) { isLockedeach = OrderProvider.LockETOLearningPoint( myCart.CartItems.Select(s => s.SKU), _distributorId, orderNumber, new OrderMonth(myCart.CountryCode).OrderMonthShortString, Convert.ToInt32(Math.Truncate(myCart.pcLearningPointOffSet)), HLConfigManager.Platform); if (!isLockedeach) { lockfailed = " Learning Point"; isLocked = false; } } if (myCart.HastakenSrPromotion) { isLockedeach = ChinaPromotionProvider.LockSRPromotion(myCart, OrderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", SR Promotion"; isLocked = false; } } if (myCart.HastakenSrPromotionGrowing) { isLockedeach = ChinaPromotionProvider.LockSRQGrowingPromotion(myCart, OrderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", SR Query Growing"; isLocked = false; } } if (myCart.HastakenSrPromotionExcelnt) { isLockedeach = ChinaPromotionProvider.LockSRQExcellentPromotion(myCart, OrderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", SR Query Excellent"; isLocked = false; } } if (myCart.HastakenBadgePromotion) { isLockedeach = ChinaPromotionProvider.LockBadgePromotion(myCart, OrderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", Badge promo"; isLocked = false; } } if (myCart.HastakenNewSrpromotion) { isLockedeach = ChinaPromotionProvider.LockNewSRPromotion(myCart, OrderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", NewSrPromotion"; isLocked = false; } } if (myCart.HasBrochurePromotion) { isLockedeach = ChinaPromotionProvider.LockBrochurePromotion(myCart, OrderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", Brochure Promotion"; isLocked = false; } } if (isLocked) { HttpContext.Current.Response.Write(response); HttpContext.Current.Response.End(); } else { LogMessageWithInfo(PaymentGatewayLogEntryType.Response, OrderNumber, _distributorId, _gatewayName, PaymentGatewayRecordStatusType.Declined, lockfailed.TrimStart(',') + " locking fails."); } }
public MobileResponseWrapper Post(WechatPrepayIdRequestViewModel request, string memberId) { if (request == null || request.Data == null || request.Data.Prepay == null || request.Data.Order == null) { throw CreateException(HttpStatusCode.BadRequest, "request is null", 500404); } string obj = JsonConvert.SerializeObject(request); SetOrderMemberId(request.Data.Order); request.Data.Prepay.Locale = Thread.CurrentThread.CurrentCulture.Name; request.Data.Prepay.MemberId = memberId; var authToken = Guid.Empty; if (null != Request && null != Request.Headers && Request.Headers.Any()) { if (Request.Headers.Contains("X-HLUSER-TOKEN")) { var authTokenValue = Request.Headers.GetValues("X-HLUSER-TOKEN").FirstOrDefault(); if (!string.IsNullOrEmpty(authTokenValue)) { Guid.TryParse(authTokenValue, out authToken); } } } WechatPrepayIdResponseViewModel result = null; var errors = new List <ValidationErrorViewModel>(); if (null != request.Data.Order) { request.Data.Order.Locale = Thread.CurrentThread.CurrentCulture.Name; var amount = decimal.Zero; var id = _mobileWechatProvider.InsertToPaymentGatewayRecord(request.Data.Order, authToken == Guid.Empty ? Guid.NewGuid() : authToken, ref amount); if (id == 0) { errors.Add(new ValidationErrorViewModel { Code = 101416, Reason = "InsertToPaymentGatewayRecord failed" }); } if (!string.IsNullOrEmpty(request.Data.Order.OrderNumber) && amount > 0) { bool isLockedeach = true; bool isLocked = true; string lockfailed = string.Empty; if (request.Data.Order.pcLearningPointOffSet > 0M && request.Data.Order.CategoryType != "ETO") { isLockedeach = OrderProvider.LockPCLearningPoint(request.Data.Prepay.MemberId, request.Data.Order.OrderNumber, request.Data.Order.OrderMonth, request.Data.Order.pcLearningPointOffSet, HLConfigManager.Platform); if (!isLockedeach) { lockfailed = "PC Learning Point"; isLocked = false; } } else if (request.Data.Order.pcLearningPointOffSet > 0M) { isLockedeach = OrderProvider.LockETOLearningPoint( request.Data.Order.OrderItems.Select(s => s.Sku), request.Data.Prepay.MemberId, request.Data.Order.OrderNumber, request.Data.Order.OrderMonth, request.Data.Order.pcLearningPointOffSet, HLConfigManager.Platform); if (!isLockedeach) { lockfailed = "ETO Learning Point"; isLocked = false; } } var shoppingcart = ShoppingCartProvider.GetShoppingCart(request.Data.Prepay.MemberId, request.Data.Prepay.Locale, true, false); if (shoppingcart.HastakenSrPromotion) { isLockedeach = ChinaPromotionProvider.LockSRPromotion(shoppingcart, request.Data.Order.OrderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", SR Promotion"; isLocked = false; } } if (shoppingcart.HastakenSrPromotionGrowing) { isLockedeach = ChinaPromotionProvider.LockSRQGrowingPromotion(shoppingcart, request.Data.Order.OrderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", SR Query Growing"; isLocked = false; } } if (shoppingcart.HastakenSrPromotionExcelnt) { isLockedeach = ChinaPromotionProvider.LockSRQExcellentPromotion(shoppingcart, request.Data.Order.OrderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", SR Query Excellent"; isLocked = false; } } if (shoppingcart.HastakenBadgePromotion) { isLockedeach = ChinaPromotionProvider.LockBadgePromotion(shoppingcart, request.Data.Order.OrderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", BadgePromotion"; isLocked = false; } } if (shoppingcart.HastakenNewSrpromotion) { isLockedeach = ChinaPromotionProvider.LockNewSRPromotion(shoppingcart, request.Data.Order.OrderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", NewSrPromotion"; isLocked = false; } } if (shoppingcart.HasBrochurePromotion) { isLockedeach = ChinaPromotionProvider.LockBrochurePromotion(shoppingcart, request.Data.Order.OrderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", BrochurePromotion"; isLocked = false; } } if (isLocked) { result = _mobileWechatProvider.GetPrepayId(request.Data.Prepay, request.Data.Order.OrderNumber, amount); } else { errors.Add(new ValidationErrorViewModel { Code = 101417, Reason = lockfailed.TrimStart(',') + " locking failed" }); } } } var response = new MobileResponseWrapper { Data = result, ValidationErrors = errors.Any() ? errors : null }; JObject json = JObject.Parse(obj); MobileActivityLogProvider.ActivityLog(json, response, memberId ?? string.Empty, true, Request.RequestUri.ToString(), Request.Headers.ToString(), Request.Headers.UserAgent.ToString(), request.Data.Prepay.Locale); return(response); }
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); } }
public override void Submit() { bool isLockedeach = true; bool isLocked = true; string lockfailed = string.Empty; var currentSession = SessionInfo.GetSessionInfo(HttpContext.Current.User.Identity.Name, _locale); if (currentSession != null) { if (currentSession.ShoppingCart != null && currentSession.ShoppingCart.pcLearningPointOffSet > 0M && !(currentSession.ShoppingCart.OrderCategory == ServiceProvider.CatalogSvc.OrderCategoryType.ETO)) { isLockedeach = OrderProvider.LockPCLearningPoint(_distributorId, OrderNumber, new OrderMonth(currentSession.ShoppingCart.CountryCode).OrderMonthShortString, Convert.ToInt32(Math.Truncate(currentSession.ShoppingCart.pcLearningPointOffSet)), HLConfigManager.Platform); if (!isLockedeach) { lockfailed = "PC Learning Point"; isLocked = false; } } else if (currentSession.ShoppingCart != null && currentSession.ShoppingCart.pcLearningPointOffSet > 0M) { isLockedeach = OrderProvider.LockETOLearningPoint( currentSession.ShoppingCart.CartItems.Select(s => s.SKU), _distributorId, OrderNumber, new OrderMonth(currentSession.ShoppingCart.CountryCode).OrderMonthShortString, Convert.ToInt32(Math.Truncate(currentSession.ShoppingCart.pcLearningPointOffSet)), HLConfigManager.Platform); if (!isLockedeach) { lockfailed = "ETO Learning Point"; isLocked = false; } } if (currentSession.ShoppingCart.HastakenSrPromotion) { isLockedeach = ChinaPromotionProvider.LockSRPromotion(currentSession.ShoppingCart, _orderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", SR Promotion"; isLocked = false; } } if (currentSession.ShoppingCart.HastakenSrPromotionGrowing) { isLockedeach = ChinaPromotionProvider.LockSRQGrowingPromotion(currentSession.ShoppingCart, _orderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", SR Query Growing"; isLocked = false; } } if (currentSession.ShoppingCart.HastakenSrPromotionExcelnt) { isLockedeach = ChinaPromotionProvider.LockSRQExcellentPromotion(currentSession.ShoppingCart, _orderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", SR Query Excellent"; isLocked = false; } } if (currentSession.ShoppingCart.HastakenBadgePromotion) { isLockedeach = ChinaPromotionProvider.LockBadgePromotion(currentSession.ShoppingCart, _orderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", Badge promo"; isLocked = false; } } if (currentSession.ShoppingCart.HastakenNewSrpromotion) { isLockedeach = ChinaPromotionProvider.LockNewSRPromotion(currentSession.ShoppingCart, _orderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", NewSrPromotion"; isLocked = false; } } } if (currentSession.ShoppingCart.HasBrochurePromotion) { isLockedeach = ChinaPromotionProvider.LockBrochurePromotion(currentSession.ShoppingCart, _orderNumber); if (!isLockedeach) { lockfailed = lockfailed + ", Brochure Promotion"; isLocked = false; } } if (isLocked) { CN_99BillQuickPayProvider provider = new CN_99BillQuickPayProvider(); var resultString = provider.Submit(_orderNumber, _orderAmount); if (!string.IsNullOrEmpty(resultString)) { var verStr = Encrypt(resultString, EncryptionKey); var url = string.Format("{0}?QPVerStr={1}", _configHelper.GetConfigEntry("paymentGatewayReturnUrlApproved"), verStr); HttpContext.Current.Response.Redirect(url, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } } else { var resultString = string.Format("{0},{1},{2},{3},{4},{5}", OrderNumber, "0", DateTime.Now.ToString(DateTimeFormat), "", "", ""); var verStr = Encrypt(resultString, EncryptionKey); var url = string.Format("{0}?QPVerStr={1}", _configHelper.GetConfigEntry("paymentGatewayReturnUrlApproved"), verStr); HttpContext.Current.Response.Redirect(url, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } }