private void ResolveAPF() { if (ShoppingCart != null && ShoppingCart.CartItems != null && APFDueProvider.IsAPFSkuPresent(ShoppingCart.CartItems)) { if (_paymentsSummary != null && _paymentsSummary.CurrentPaymentInfo != null && _paymentsSummary.CurrentPaymentInfo.Any()) { CreditPayment_V01 payment = _paymentsSummary.CurrentPaymentInfo[0] as CreditPayment_V01; if (payment == null) { return; } if (this.Locale == "pt-BR" && payment.AuthorizationMethod != AuthorizationMethodType.Online) { return; } DistributorOrderingProfile orderingProfile = this.DistributorOrderingProfile; if (orderingProfile != null) { int payedApf = APFDueProvider.APFQuantityInCart(ShoppingCart); var currentDueDate = orderingProfile.ApfDueDate; var newDueDate = currentDueDate + new TimeSpan(payedApf * 365, 0, 0, 0); orderingProfile.ApfDueDate = newDueDate; Session.Add("apfdue", newDueDate); APFDueProvider.UpdateAPFDuePaid(DistributorID, newDueDate); new DistributorOrderingProfileFactory().ReloadDistributorOrderingProfile(DistributorID, CountryCode); } } } }
private string GetCardType(CreditPayment_V01 payment) { string theCardType = string.Empty; switch (payment.Card.IssuerAssociation) { case IssuerAssociationType.Visa: { theCardType = "VI"; break; } case IssuerAssociationType.MasterCard: { theCardType = "MC"; break; } case IssuerAssociationType.AmericanExpress: { theCardType = "AX"; break; } default: { theCardType = "VI"; break; } } return(theCardType); }
private PeruPaymentGateWayInvoker(string paymentMethod, decimal amount) : base("PeruPaymentGateway", paymentMethod, amount) { CreditPayment_V01 payment = HttpContext.Current.Session[PaymentGatewayInvoker.PaymentInformation] as CreditPayment_V01; if (null != payment) { string invokerType = string.Empty; switch (payment.Card.IssuerAssociation) { case IssuerAssociationType.Visa: { invokerType = "MultiMerchantVisaNetPaymentGatewayInvoker"; HttpContext.Current.Session.Remove(PaymentGatewayInvoker.PaymentInformation); break; } case IssuerAssociationType.MasterCard: { invokerType = "PuntoWebPaymentGatewayInvoker"; break; } } object[] args = new object[] { paymentMethod, amount }; Type type = Type.GetType(string.Concat(RootNameSpace, invokerType), true, true); _theInvoker = Activator.CreateInstance(type, BindingFlags.NonPublic | BindingFlags.Instance, null, args, null) as PaymentGatewayInvoker; } }
protected override void fillPaymentInfo() { base.fillPaymentInfo(); string paymentGatewayLogs = string.Empty; CreditPayment_V01 payment = CurrentPaymentInfo as CreditPayment_V01; if (null != payment) { pnlAlternatePayment.Visible = false; pnlCardPayments.Visible = true; trCardHolderName.Visible = false; trCardType.Visible = false; trCardExpDate.Visible = false; trAmountText.Visible = true; trPaymentOptions.Visible = true; trAddress.Visible = false; if (payment.Card.IssuerAssociation.ToString() == IssuerAssociationType.GenericDebitCard.ToString()) { lblCardNumber.Text = "N/A"; } else { lblCardNumber.Text = payment.Card.AccountNumber.Trim(); } if ((this.Page as ProductsBase).CountryCode == "RS") { lblCardNumber.Text = "--"; lblUrl.Text = "rs.myherbalife.com"; ResponseContext _responseContext; paymentGatewayLogs = OrderProvider.GetPaymentGatewayLog((this.Page as ProductsBase).OrderNumber, PaymentGatewayLogEntryType.Response).Where(l => l.Contains("result=CAPTURED") || l.Contains("result:=CAPTURED")).FirstOrDefault(); if (!string.IsNullOrEmpty(paymentGatewayLogs)) { _responseContext = new ResponseContext(paymentGatewayLogs); if (_responseContext.PostedValues.AllKeys.Contains("result")) { if (!string.IsNullOrEmpty(_responseContext.PostedValues["auth"])) { lblAuthorizationCode.Text = _responseContext.PostedValues["auth"]; } } } } else { lblAuthorizationCode.Text = payment.AuthorizationCode; } lblAmount.Text = payment.Amount.ToString(); lblTransactionDate.Text = System.DateTime.Today.ToShortDateString(); lblPayOptions.Text = (payment.PaymentOptions as PaymentOptions_V01).NumberOfInstallments.ToString(); lblInstallmentType.Text = payment.AuthorizationMerchantAccount; // Installment Type; borrow the Auth Merchant field to place the data } }
//private string GetCardName(IssuerAssociationType issuer) //{ // string card = issuer.ToString(); // switch (issuer) // { // case IssuerAssociationType.APlus: // { // card = GetLocalResourceObject("PayByAPlus") as string; // break; // } // case IssuerAssociationType.MyKey: // { // card = GetLocalResourceObject("PayByMyKey") as string; // break; // } // } // return card; //} /// <summary>Mask the card number for display</summary> /// <param name="cardNum">The card number</param> /// <returns>The masked value</returns> protected string getCardName(CreditPayment_V01 payment) { if (payment is KoreaISPPayment_V01 || payment is KoreaMPIPayment_V01) { return(payment.Card.IssuingBankID); } string cardTypeAbbrev = CreditCard.CardTypeToHPSCardType(payment.Card.IssuerAssociation); string cardName = cardTypeAbbrev; if (!string.IsNullOrEmpty(cardName)) { cardName = GetGlobalResourceObject(string.Format("{0}_GlobalResources", HLConfigManager.Platform), string.Format("CardType_{0}_Description", cardTypeAbbrev)) as string; } return(cardName); }
public override Payment GetPaymentInfo() { CreditPayment_V01 payment = base.GetBasePaymentInfo() as CreditPayment_V01; payment.Card.AccountNumber = txtCardNumber.Text.ToString().Trim(); payment.Card.CVV = txtCVV.Text.ToString().Trim(); payment.Card.Expiration = convertExpDateToDatetimeFormat(); string payCode = ddlCards.SelectedValue; if (!string.IsNullOrEmpty(payCode)) { payment.Card.IssuerAssociation = CreditCard.GetCardType(payCode); } Session.Remove(PaymentGatewayInvoker.PaymentInformation); Session.Add(PaymentGatewayInvoker.PaymentInformation, payment); return(payment); }
public override List <Payment> GetPayments(Address_V01 shippingAddress) { var paymentList = new List <Payment>(); CheckForPaymentGatewayResponse(); var choice = GetCurrentPaymentOptionOverride(); switch (choice) { case PaymentOptionChoiceOverride.WireTransfer: // Pay by Phone { paymentList.Add(CreateDummyPayment(shippingAddress)); (paymentList.First()).TransactionType = "DB"; break; } case PaymentOptionChoiceOverride.PaymentGateway: // eBanking { paymentList.Add(CreateDummyPayment(shippingAddress)); (paymentList.First()).TransactionType = "10"; break; } case PaymentOptionChoiceOverride.Bill99: // 99 bill { paymentList.Add(CreateDummyPayment(shippingAddress)); (paymentList.First()).TransactionType = "12"; Session.Remove(PaymentGatewayInvoker.PaymentInformation); Session.Add(PaymentGatewayInvoker.PaymentInformation, paymentList.First()); break; } case PaymentOptionChoiceOverride.CreditCard: // CNP { var paymentInfo = GetCurrentPaymentInformation(_locale, _distributorId); // Check mobile controls first if (!string.IsNullOrEmpty(txtCardNumberMob.Text) && ddlBankdsMob.SelectedItem != null && !string.IsNullOrEmpty(txtExpMonthMob.Text) && !string.IsNullOrEmpty(txtExpYearMob.Text) && !string.IsNullOrEmpty(txtCVVMob.Text)) { decimal amount = 0; int cardMobileId = 0; int.TryParse(txtCardIdMob.Text, out cardMobileId); if (decimal.TryParse(txtAmountMob.Text, out amount) && cardMobileId > 0) { var info = (paymentInfo != null && paymentInfo.Count > 0) ? paymentInfo[0] : new PaymentInformation(); info.CardHolder = new Name_V01(); var payment = new CreditPayment_V01(); info.Amount = amount; payment.Card = new CreditCard(); payment.AuthorizationMethod = AuthorizationMethodType.Online; payment.Card.IssuerAssociation = IssuerAssociationType.None; payment.Amount = amount; payment.Address = shippingAddress; info.CardNumber = payment.Card.AccountNumber = CryptographicProvider.Encrypt(txtCardNumberMob.Text.Trim()); payment.Card.CVV = CryptographicProvider.Encrypt(txtCVVMob.Text.Trim()); payment.AuthorizationCode = string.Empty; info.Expiration = payment.Card.Expiration = getExpDate(txtExpMonthMob.Text, txtExpYearMob.Text); info.AuthorizationFailures = 0; if (isExpires(info.Expiration)) { //info.AuthorizationFailures = 3; imgDeclinedMob.ImageUrl = GetStatusImageUrl(info.ID); imgDeclinedMob.ToolTip = GetStatusImageToolTip(info.ID); imgDeclinedMob.Visible = true; lblErrorMessages.Text = PlatformResources.GetGlobalResourceString("ErrorMessage", "CardExpiredForSavedCard"); } payment.Card.NameOnCard = string.Empty; payment.AuthorizationMerchantAccount = ddlBankdsMob.SelectedItem != null ? ddlBankdsMob.SelectedValue : string.Empty; payment.Currency = HLConfigManager.Configurations.CheckoutConfiguration.Currency.Trim(); payment.Address = (null != info.BillingAddress) ? info.BillingAddress : shippingAddress; payment.PaymentOptions = new PaymentOptions_V01 { NumberOfInstallments = 1 }; info.Options = payment.PaymentOptions; payment.TransactionType = "CC"; paymentList.Add(payment); Session.Remove(PaymentGatewayInvoker.PaymentInformation); Session.Add(PaymentGatewayInvoker.PaymentInformation, payment); SetCurrentPaymentInformation(paymentInfo, _locale, _distributorId); } break; } foreach (GridViewRow row in gridViewCardInfo.Rows) { var txtCVV = row.FindControl("txtCVV") as TextBox; var txtAmount = row.FindControl("txtAmount") as TextBox; var txtCardNumber = row.FindControl("txtCardNumber") as TextBox; var txtExpMonth = row.FindControl("txtExpMonth") as TextBox; var txtExpYear = row.FindControl("txtExpYear") as TextBox; var id = row.FindControl("cardID") as TextBox; var currentOptions = row.FindControl("lnkPaymentOptions") as LinkButton; var banks = row.FindControl("ddlCards") as DropDownList; // list of banks int cardID = int.Parse(id.Text); decimal cardAmount; if (decimal.TryParse(txtAmount.Text, out cardAmount) && cardID > 0) { var info = (paymentInfo != null && paymentInfo.Count > 0) ? paymentInfo[0] : new PaymentInformation(); info.CardHolder = new Name_V01(); var payment = new CreditPayment_V01(); info.Amount = cardAmount; payment.Card = new CreditCard(); payment.AuthorizationMethod = AuthorizationMethodType.Online; payment.Card.IssuerAssociation = IssuerAssociationType.None; payment.Amount = cardAmount; payment.Address = shippingAddress; info.CardNumber = payment.Card.AccountNumber = CryptographicProvider.Encrypt(txtCardNumber.Text.Trim()); payment.Card.CVV = CryptographicProvider.Encrypt(txtCVV.Text.Trim()); payment.AuthorizationCode = string.Empty; info.Expiration = payment.Card.Expiration = getExpDate(txtExpMonth.Text, txtExpYear.Text); info.AuthorizationFailures = 0; if (isExpires(info.Expiration)) { //info.AuthorizationFailures = 3; var img = row.FindControl("imgDeclined") as Image; if (null != img) { img.ImageUrl = GetStatusImageUrl(info.ID); img.ToolTip = GetStatusImageToolTip(info.ID); img.Visible = true; } lblErrorMessages.Text = PlatformResources.GetGlobalResourceString("ErrorMessage", "CardExpiredForSavedCard"); } payment.Card.NameOnCard = string.Empty; payment.AuthorizationMerchantAccount = banks.SelectedItem != null ? banks.SelectedValue : string.Empty; payment.Currency = HLConfigManager.Configurations.CheckoutConfiguration.Currency.Trim(); payment.Address = (null != info.BillingAddress) ? info.BillingAddress : shippingAddress; payment.PaymentOptions = new PaymentOptions_V01 { NumberOfInstallments = 1 }; info.Options = payment.PaymentOptions; payment.TransactionType = "CC"; SetPaymentOptions(info, row); payment.ReferenceID = currentOptions.Text; paymentList.Add(payment); Session.Remove(PaymentGatewayInvoker.PaymentInformation); Session.Add(PaymentGatewayInvoker.PaymentInformation, payment); SetCurrentPaymentInformation(paymentInfo, _locale, _distributorId); } } break; } case PaymentOptionChoiceOverride.QuickPay: // Quick Pay { var payment = new CreditPayment_V01(); payment.TransactionType = "QP"; payment.Currency = HLConfigManager.Configurations.CheckoutConfiguration.Currency.Trim(); payment.AuthorizationMerchantAccount = BankList_QuickPay.SelectedValue; var card = new QuickPayPayment(); if (IsNewQuickPayRegistration()) { var membershipUser = (MembershipUser <DistributorProfileModel>)Membership.GetUser(); var name = string.Empty; if (membershipUser != null) { name = membershipUser.Value.DistributorName(); } if (!string.IsNullOrEmpty(CardCVV_QuickPay.Text)) { card.CVV = CryptographicProvider.Encrypt(CardCVV_QuickPay.Text); } card.AccountNumber = CryptographicProvider.Encrypt(CardNumber_QuickPay.Text.Trim()); card.CardHolderId = IdentityNumber_QuickPay.Text; card.CardHolderType = "0"; //CNID card.NameOnCard = name; card.MobilePhoneNumber = PhoneNumber_QuickPay.Text; int expiredMonth = 0; int expiredYear = 0; DateTime tmpDate = DateTime.Now; if (int.TryParse(CardExpiredDate_Month_QuickPay.Text, out expiredMonth) && int.TryParse("20" + CardExpiredDate_Year_QuickPay.Text, out expiredYear) && DateTime.TryParseExact("01/" + CardExpiredDate_Month_QuickPay.Text + "/20" + CardExpiredDate_Year_QuickPay.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out tmpDate)) { card.Expiration = new DateTime(expiredYear, expiredMonth, 1); } } else { card.AccountNumber = CryptographicProvider.Encrypt(CardNumberLabel_QuickPay.Text.Trim()); card.StorablePAN = card.AccountNumber; card.CardHolderId = IdentityNumberLabel_QuickPay.Text; card.CardHolderType = "0"; //CNID card.MobilePhoneNumber = PhoneNumberLabel_QuickPay.Text; } card.IssuingBankID = BankList_QuickPay.SelectedValue; card.IsDebitCard = IsQuickPayDebitCard(); card.BindCard = BindCard_QuickPay.Checked; payment.Card = card; payment.Amount = GetTotals().AmountDue; paymentList.Add(payment); Session.Remove(PaymentGatewayInvoker.PaymentInformation); Session.Add(PaymentGatewayInvoker.PaymentInformation, payment); break; } } string currentKey = PaymentsConfiguration.GetCurrentPaymentSessionKey(_locale, _distributorId); Session[currentKey] = paymentList; return(paymentList); }
public override void GetPaymentInfo(SerializedOrderHolder holder) { ServiceProvider.SubmitOrderBTSvc.Payment payment = holder.BTOrder.Payments[0]; CreditPayment_V01 orderPayment = (holder.Order as Order_V01).Payments[0] as CreditPayment_V01; List <string> PaymentGatewayLog = OrderProvider.GetPaymentGatewayLog(OrderNumber, PaymentGatewayLogEntryType.Response); string theOne = PaymentGatewayLog.Find(i => i.Contains(CardNum)); if (!string.IsNullOrEmpty(theOne)) { NameValueCollection theResponse = GetRequestVariables(theOne); // Card Number if (!string.IsNullOrEmpty(theResponse[CardNum])) { CardNumber = theResponse[CardNum]; } // Authorization Code if (!string.IsNullOrEmpty(theResponse[AuthCode])) { base.AuthorizationCode = theResponse[AuthCode]; } base.GetPaymentInfo(holder); //WebPay Amount if (!string.IsNullOrEmpty(theResponse[Amount])) { payment.Amount = Int32.Parse(theResponse[Amount]); } orderPayment.Amount = payment.Amount; // Number of Installments PaymentOptions_V01 options = new PaymentOptions_V01(); if (!string.IsNullOrEmpty(theResponse[InstallmentNumber])) { options.NumberOfInstallments = Int32.Parse(theResponse[InstallmentNumber]); } else { options.NumberOfInstallments = 1; } payment.NumberOfInstallments = options.NumberOfInstallments; orderPayment.PaymentOptions = options; // Installment Type is Card Type (VN for credit card, VD for debit card); borrow the Auth Merchant field to place the data to display on the page if (!string.IsNullOrEmpty(theResponse[InstallmentType])) { payment.AuthMerchant = theResponse[InstallmentType]; switch (theResponse[InstallmentType].ToString().ToUpper()) { case "VN": CardType = IssuerAssociationType.Visa; break; case "VD": CardType = IssuerAssociationType.GenericDebitCard; break; default: CardType = IssuerAssociationType.Visa; break; } } orderPayment.AuthorizationMerchantAccount = payment.AuthMerchant; } }
private Payment CreateDummyPayment(Address_V01 address) { Payment payment = null; var cc = new CreditCard(); cc.IssuerAssociation = CreditCard.GetCardType("VI"); cc.AccountNumber = PaymentInfoProvider.VisaCardNumber; cc.CVV = "123"; cc.Expiration = new DateTime(2012, 2, 1); cc.NameOnCard = "Test Card"; switch (GetCurrentPaymentOption()) { case PaymentOptionChoice.CreditCard: { var cp = new CreditPayment_V01(); var options = new PaymentOptions_V01(); options.NumberOfInstallments = 1; cp.PaymentOptions = options; cp.AuthorizationMethod = AuthorizationMethodType.Online; cp.AuthorizationCode = "123456"; cp.Card = cc; payment = cp; break; } case PaymentOptionChoice.PaymentGateway: { var cp = new CreditPayment_V01(); var options = new PaymentOptions_V01(); options.NumberOfInstallments = 1; string payCode = HLConfigManager.Configurations.PaymentsConfiguration.PaymentGatewayPayCode; if (!string.IsNullOrEmpty(payCode)) { cc.IssuerAssociation = CreditCard.GetCardType(payCode); } cp.Card = cc; cp.PaymentOptions = options; cp.AuthorizationMethod = AuthorizationMethodType.PaymentGateway; cp.TransactionType = HLConfigManager.Configurations.PaymentsConfiguration.PaymentGatewayAlias; cp.AuthorizationCode = "654321"; //cp.TransactionID = (null != _paymentGatewayResponse) ? _paymentGatewayResponse.TransactionCode : Guid.NewGuid().ToString(); cp.Card = cc; payment = cp; break; } case PaymentOptionChoice.WireTransfer: { var wp = new WirePayment_V01(); wp.TransactionType = ddlWire.SelectedItem.Text; wp.PaymentCode = ddlWire.SelectedValue; wp.ReferenceID = DistributorOrderingProfile.ReferenceNumber; wp.TransactionType = GetLocalResourceObject("ListItemResource3.Text") as string + ddlWire.SelectedItem.Text; payment = wp; break; } case PaymentOptionChoice.DirectDeposit: { var wp = new DirectDepositPayment_V01(); wp.PaymentCode = ddlDirectDeposit.SelectedValue; wp.ReferenceID = DistributorOrderingProfile.ReferenceNumber; wp.TransactionType = string.Format("{0}{1}", GetLocalResourceObject("ListItemResource4.Text") as string, ddlDirectDeposit.Items.Count > 1 ? string.Format("/{0}", ddlDirectDeposit.SelectedItem.Text) : string.Empty); payment = wp; break; } } if (null == address) { address = new Address_V01(); //address = new Address_V01(); //address.City = "Torrance"; //address.Country = _countryCode; //address.CountyDistrict = "Los Angeles"; //address.Line1 = "950W 190th Street"; //address.PostalCode = "90502"; //address.StateProvinceTerritory = "CA"; } if (null == payment.Address) { payment.Address = address; } payment.Address = address; payment.Amount = GetTotals().AmountDue; payment.Currency = HLConfigManager.Configurations.CheckoutConfiguration.Currency; return(payment); }
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); } }
protected virtual void fillPaymentInfo() { try { pnlAlternatePayment.Visible = false; pnlCardPayments.Visible = true; trPaymentOptions.Visible = false; if (_paymentInfo != null) { if (_paymentInfo is WirePayment_V01 || _paymentInfo is DirectDepositPayment_V01 || (_paymentInfo is CreditPayment_V01 && (_paymentInfo as CreditPayment_V01).AuthorizationMethod == AuthorizationMethodType.PaymentGateway && !HLConfigManager.Configurations.PaymentsConfiguration.ShowPaymentInfoForPaymentGatewayInSummary)) { lblAlternatePaymentMethod.Text = _paymentInfo.TransactionType; lblAlternateAmount.Text = getAmountString(_paymentInfo.Amount, true); if ((this.Page as ProductsBase).CountryCode == "ZA" && (_paymentInfo is CreditPayment_V01 && (_paymentInfo as CreditPayment_V01).AuthorizationMethod == AuthorizationMethodType.PaymentGateway)) { lblAlternatePaymentMethod.Text = HLConfigManager.Configurations.PaymentsConfiguration.PaymentGatewayAlias; } //Defect 82562 for SI adding the prefix to the if ((this.Page as ProductsBase).CountryCode == "SI") { lblReference.Text = "SI00" + (this.Page as ProductsBase).OrderNumber; } else { lblReference.Text = (this.Page as ProductsBase).OrderNumber; } // defect 24438 for MX. please remove 2T from the reference number. if ((this.Page as ProductsBase).CountryCode == "MX") { if (!String.IsNullOrEmpty(lblReference.Text) && lblReference.Text.Length > 3) { lblReference.Text = lblReference.Text.Substring(2); } this.mxReference.Style.Remove("display"); this.lblReferenceMX.Text = _paymentInfo.ReferenceID; //ReferenceNumber and ReferenceID are coming as null. // need n0n-null to display it on the website for MX // defect 24438 - Wire confirmation reference is null //string ref1 = (_paymentInfo as WirePayment_V01).ReferenceNumber; //string ref2 = (_paymentInfo as WirePayment_V01).ReferenceID; } else if ((this.Page as ProductsBase).CountryCode == "VE") { // Print reference for VE only for direct deposit payment method. var ddVE = _paymentInfo as DirectDepositPayment_V01; if (ddVE != null) { this.mxReference.Style.Remove("display"); this.lblReferenceMX.Text = ddVE.ReferenceID; } } wireMessage.SectionName = "Ordering"; wireMessage.UseLocal = true; if (_paymentInfo is WirePayment_V01) { if ((this.Page as ProductsBase).CountryCode == "TW" && (_paymentInfo as WirePayment_V01).PaymentCode == "W1") { wireMessage.ContentPath = "lblWireMessageWithSMS.html"; } else if (_paymentInfo.TransactionType.Trim() == "ICICI Bank iSure Pay (Auto Order Release)") { wireMessage.ContentPath = "lblWireTransferAutoOrderRelease.html"; } else if (HLConfigManager.Configurations.PaymentsConfiguration.MultipleWireMessage) { GetWireMessage((_paymentInfo as WirePayment_V01).PaymentCode); } else { wireMessage.ContentPath = "lblWireMessage.html"; } wireMessage.LoadContent(); } else if (_paymentInfo is DirectDepositPayment_V01) { wireMessage.ContentPath = "lblDirectDepositMessage.html"; } pnlAlternatePayment.Visible = true; pnlCardPayments.Visible = false; } else if (_paymentInfo is CreditPayment_V01) { CreditPayment_V01 payment = _paymentInfo as CreditPayment_V01; List <PaymentInformation> CurrentCreditCardInfo = this.GetCurrentPaymentInformation(_locale, _distributorId); string cardNum = null; if (HLConfigManager.Configurations.DOConfiguration.IsChina) { #region 146947 : china stuffs cardNum = HL.Common.Utilities.CryptographicProvider.Decrypt(payment.Card.AccountNumber.Trim()); if (!string.IsNullOrEmpty(cardNum)) { cardNum = (cardNum.Length > 4 ? new string('X', cardNum.Length - 4) : "") + cardNum.Substring(cardNum.Length - 4); } #endregion } else { cardNum = payment.Card.AccountNumber.Trim(); if (!string.IsNullOrEmpty(cardNum)) { cardNum = "-" + (cardNum.Length > 4 ? cardNum.Substring(cardNum.Length - 4) : cardNum); } } if (CurrentCreditCardInfo != null && CurrentCreditCardInfo.Count > 0 && CurrentCreditCardInfo.Count == 1) { PaymentInformation pi = CurrentCreditCardInfo[0] as PaymentInformation; if (pi != null && pi.CardHolder != null) { lblCardHolderName.Text = pi.CardHolder.First + " " + pi.CardHolder.Middle + " " + pi.CardHolder.Last; lblCardType.Text = pi.CardType; } } else { lblCardHolderName.Text = payment.Card.NameOnCard; lblCardType.Text = getCardName(payment); } lblCardNumber.Text = cardNum; lblCardExpiration.Text = GetExpirationInfo(); lblAmount.Text = getAmountString(_paymentInfo.Amount); if (HLConfigManager.Configurations.PaymentsConfiguration.AddressRequiredForNewCard) { lblBillingAddress.Text = GetFormattedBillingAddress(); } else { lblBillingAddress.Visible = false; lblBillingAddressText.Visible = false; } if (null != payment.PaymentOptions && null != payment.PaymentOptions as JapanPaymentOptions_V01) { if ((payment.PaymentOptions as JapanPaymentOptions_V01).ChargeMode != JapanPayOptionType.Unknown) { lblPayOptions.Text = payment.ReferenceID; trPaymentOptions.Visible = true; } } } else if (_paymentInfo is LocalPayment_V01) { var pnm = _paymentInfo as LocalPayment_V01; if (pnm.PaymentCode.Trim() == "PN") { var currentSession = SessionInfo.GetSessionInfo(this.DistributorID, this.Locale); wireMessage.SectionName = "Ordering"; wireMessage.UseLocal = true; wireMessage.ContentPath = "lblPayNearMeMessage.html"; wireMessage.LoadContent(); lblReference.Text = (this.Page as ProductsBase).OrderNumber; lblAlternatePaymentMethod.Text = pnm.TransactionType; lblAlternateAmount.Text = getAmountString(pnm.Amount, true); if (!string.IsNullOrEmpty(currentSession.LocalPaymentId)) { this.mxReference.Style.Remove("display"); this.divHelpIcon.Style.Remove("display"); this.lblReferenceMX.Text = string.IsNullOrEmpty(currentSession.TrackingUrl) ? currentSession.LocalPaymentId : string.Format("<a href='{0}' target='_blank'>{1}</a>", currentSession.TrackingUrl, currentSession.LocalPaymentId); } } pnlAlternatePayment.Visible = true; pnlCardPayments.Visible = false; } trAmountText.Visible = HLConfigManager.Configurations.PaymentsConfiguration.ShowPaymentAmountsInSummary; } if ((this.Page as ProductsBase).CountryCode == "CN") { trCardHolderName.Visible = false; trCardType.Visible = false; } } catch (Exception ex) { LoggerHelper.Error( String.Format( "Messages:{0}, StackTrace:{1}, Locale:{2}, DistributorId:{3},PaymentInfo Payment Date:{4},PaymentInfo Transaction Type: {5}", ex.Message, ex.StackTrace, _locale, _distributorId, _paymentInfo != null ? _paymentInfo.PaymentDate != null ? _paymentInfo.PaymentDate.Value.ToString() : "payment Date empty" : "_paymentInfo is Null", _paymentInfo != null ? _paymentInfo.TransactionType : string.Empty)); } }
protected override void fillPaymentInfo() { base.fillPaymentInfo(); CreditPayment_V01 payment = CurrentPaymentInfo as CreditPayment_V01; if (null != payment) { pnlAlternatePayment.Visible = false; pnlCardPayments.Visible = true; trCardHolderName.Visible = false; trCardType.Visible = false; trCardExpDate.Visible = false; trAmountText.Visible = true; trPaymentOptions.Visible = true; trAddress.Visible = false; lblCardNumber.Text = "--"; lblUrl.Text = "rs.myherbalife.com"; List <string> PaymentGatewayLog = OrderProvider.GetPaymentGatewayLog((this.Page as ProductsBase).OrderNumber, PaymentGatewayLogEntryType.Response); string theOne = PaymentGatewayLog.Find(i => i.Contains("result=CAPTURED") || i.Contains("result:=CAPTURED")); if (!string.IsNullOrEmpty(theOne)) { trNestPayOrderId.Visible = trNestPayAuthCode.Visible = trNestPayPaymentCode.Visible = trNestPayTransStatus.Visible = trNestPayTransCode.Visible = trNestPayTransDate.Visible = tr3DTransStatus.Visible = false; NameValueCollection theResponse = GetRequestVariables(theOne); // Authorization Code if (!string.IsNullOrEmpty(theResponse["auth"])) { lblAuthorizationCode.Text = theResponse["auth"]; } // Authorization Code if (!string.IsNullOrEmpty(theResponse["paymentid"])) { lblPaymentCode.Text = theResponse["paymentid"]; } // Authorization Code if (!string.IsNullOrEmpty(theResponse["tranid"])) { lblTransactionCode.Text = theResponse["tranid"]; } lblAmount.Text = string.Concat(payment.Amount.ToString(), HLConfigManager.Configurations.CheckoutConfiguration.CurrencySymbol); lblTransactionDate.Text = DateUtils.GetCurrentLocalTime(CountryCode).ToString(); lblPayOptions.Text = (payment.PaymentOptions as PaymentOptions_V01).NumberOfInstallments.ToString(); lblInstallmentType.Text = payment.AuthorizationMerchantAccount; // Installment Type; borrow the Auth Merchant field to place the data } else { trAmountText.Visible = trPaymentOptions.Visible = trTrasanctionDate.Visible = trAuthorizationCode.Visible = trPaymentCode.Visible = trTransactionCode.Visible = false; theOne = PaymentGatewayLog.Find(i => i.Contains("QueryString: Agency:=NestPay")); if (!string.IsNullOrEmpty(theOne)) { NameValueCollection theResponse = GetRequestVariables(theOne); // order ID if (!string.IsNullOrEmpty(theResponse["oid"])) { lblOrderId.Text = theResponse["oid"]; } // Authorization Code if (!string.IsNullOrEmpty(theResponse["AuthCode"])) { lblAuthorizationCode2.Text = theResponse["AuthCode"]; } // Payment Status if (!string.IsNullOrEmpty(theResponse["Response"])) { lblPaymentCode2.Text = theResponse["Response"]; } // Transaction Status Code if (!string.IsNullOrEmpty(theResponse["ProcReturnCode"])) { lblTransactionStatus.Text = theResponse["ProcReturnCode"]; } // Transaction ID if (!string.IsNullOrEmpty(theResponse["TransId"])) { lblTransactionCode2.Text = theResponse["TransId"]; } // Transaction Date if (!string.IsNullOrEmpty(theResponse["EXTRA.TRXDATE"])) { lblTransactionDate2.Text = theResponse["EXTRA.TRXDATE"]; } // Status code for the 3D transaction if (!string.IsNullOrEmpty(theResponse["mdStatus"])) { lbl3DTransactionStatus.Text = theResponse["mdStatus"]; } } } } }