/// <summary>Stashes the current list of PaymentInformation into the users session</summary>
        /// <param name="payment"></param>
        /// <param name="locale">The current locale</param>
        /// <param name="distributorID">The current Distributor</param>
        private void SetPaymentInformation(List <CreditPayment> payments)
        {
            string key = PaymentsConfiguration.GetCurrentPaymentSessionKey(string.Empty, string.Empty);

            if (null != payments)
            {
                if (payments.Count > 0)
                {
                    Session.Add(key, payments);
                }
                else
                {
                    Session.Add(key, new List <CreditPayment>(new[] { new CreditPayment {
                                                                          LineID = "0"
                                                                      } }));
                }
            }
            else
            {
                if (null == Session[key])
                {
                    Session.Add(key, new List <CreditPayment>(new[] { new CreditPayment {
                                                                          LineID = "0"
                                                                      } }));
                }
            }

            _CurrentPaymentsList = Session[key] as List <CreditPayment>;
        }
Exemplo n.º 2
0
        protected override void SetupPaymentMethodDisplay()
        {
            base.SetupPaymentMethodDisplay();

            if (!DistributorOrderingProfile.IsPayByPhoneEnabled || SessionInfo.IsEventTicketMode)
            {
                rblPaymentOptions.Items[2].Attributes.Add(HtmlTextWriterAttribute.Style.ToString(), "display:none");
            }

            PaymentsConfiguration _paymentsConfig = HLConfigManager.Configurations.PaymentsConfiguration;

            if (!_paymentsConfig.AllowQuickPayPayment)
            {
                rblPaymentOptions.Items[0].Attributes.Add(HtmlTextWriterAttribute.Style.ToString(), "display:none");
                rblPaymentOptions.Items[1].Selected = true;
                rblPaymentOptions.SelectedIndex     = 1;
                pnlQuickPayTable.Visible            = false;
                pnlPaymentGatewayTable.Visible      = true;
            }

            if (!_paymentsConfig.AllowCNPPayment)
            {
                rblPaymentOptions.Items[5].Attributes.Add(HtmlTextWriterAttribute.Style.ToString(), "display:none");
                pnlCreditTable.Visible = false;
            }
            if (!_paymentsConfig.AllowDirectDepositPayment)
            {
                rblPaymentOptions.Items[4].Attributes.Add(HtmlTextWriterAttribute.Style.ToString(), "display:none");
                pnlDirectDepositTable.Visible = false;
            }
        }
        /// <summary>Retrieves all the current Payment choices from the user</summary>
        /// <param name="shippingAddress">dunno</param>
        /// <returns>The list of Payments to submit for the order</returns>
        public List <Payment> GetPayments(Address_V01 shippingAddress)
        {
            var paymentList = new List <Payment>();
            var choice      = GetCurrentPaymentOption();

            switch (choice)
            {
            case PaymentOptionChoice.DirectDeposit:
            case PaymentOptionChoice.WireTransfer:
            case PaymentOptionChoice.PaymentGateway:
            {
                paymentList.Add(CreateDummyPayment(shippingAddress));
                break;
            }

            case PaymentOptionChoice.CreditCard:
            {
                paymentList =
                    new List <Payment>(
                        (from p in GetPaymentInformation()
                         where !string.IsNullOrEmpty(p.AuthorizationCode)
                         select p as Payment).ToList());
                break;
            }
            }

            string currentKey = PaymentsConfiguration.GetCurrentPaymentSessionKey(_locale, _distributorId);

            Session[currentKey] = paymentList;
            return(paymentList);
        }
Exemplo n.º 4
0
        private void BindData(PaymentsConfiguration paymentsConfiguration)
        {
            txtUsername.Text = paymentsConfiguration.Username;
            txtPassword.Text = paymentsConfiguration.Password;
            txtApiUrl.Text   = paymentsConfiguration.ApiUrl;

            txtKlarnaLogoUrl.Text          = paymentsConfiguration.LogoUrl;
            txtColorDetails.Text           = paymentsConfiguration.WidgetDetailsColor;
            txtColorButton.Text            = paymentsConfiguration.WidgetButtonColor;
            txtColorButtonText.Text        = paymentsConfiguration.WidgetButtonColor;
            txtColorCheckbox.Text          = paymentsConfiguration.WidgetCheckboxColor;
            txtColorCheckboxCheckmark.Text = paymentsConfiguration.WidgetCheckboxCheckmarkColor;
            txtColorHeader.Text            = paymentsConfiguration.WidgetHeaderColor;
            txtColorLink.Text           = paymentsConfiguration.WidgetLinkColor;
            txtColorBorder.Text         = paymentsConfiguration.WidgetBorderColor;
            txtColorBorderSelected.Text = paymentsConfiguration.WidgetSelectedBorderColor;
            txtColorText.Text           = paymentsConfiguration.WidgetTextColor;
            txtColorTextSecondary.Text  = paymentsConfiguration.WidgetTextSecondaryColor;
            txtRadiusBorder.Text        = paymentsConfiguration.WidgetBorderRadius;

            txtConfirmationUrl.Text = paymentsConfiguration.ConfirmationUrl;
            txtNotificationUrl.Text = paymentsConfiguration.NotificationUrl;
            SendProductAndImageUrlCheckBox.Checked = paymentsConfiguration.SendProductAndImageUrlField;
            UseAttachmentsCheckBox.Checked         = paymentsConfiguration.UseAttachments;
            PreAssesmentCheckBox.Checked           = paymentsConfiguration.CustomerPreAssessment;
            AutoCaptureCheckBox.Checked            = paymentsConfiguration.AutoCapture;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            _page               = Page as ProductsBase;
            _paymentsConfig     = HLConfigManager.Configurations.PaymentsConfiguration;
            _enableInstallments = _paymentsConfig.EnableInstallments;
            installmentCards    = new List <CardInfo>();

            GetCardsList();

            if (_cards != null)
            {
                installmentCards = _cards.Card.FindAll(c => c.InstallmentFees.Count > 0);

                if (!IsPostBack)
                {
                    if (installmentCards.Count > 0)
                    {
                        ddlCards.DataSource = installmentCards;
                        ddlCards.DataBind();
                        RecalcPage();
                        upInstallments.Update();
                        onPaymentInfoChanged(this, null);
                    }
                }
            }
        }
 public void AuthorizationDone(object sender, EventArgs e)
 {
     if (null == e as CreditCardAuthorizationFailedEventArgs)
     {
         Session.Remove(PaymentsConfiguration.GetCurrentPaymentSessionKey(string.Empty, string.Empty));
         if (null != _CurrentPaymentsList)
         {
             _CurrentPaymentsList.Clear();
         }
     }
 }
Exemplo n.º 7
0
 private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart,
                                             ShoppingCartRuleReason reason,
                                             ShoppingCartRuleResult Result)
 {
     if (reason == ShoppingCartRuleReason.CartItemsBeingAdded ||
         reason == ShoppingCartRuleReason.CartItemsBeingRemoved)
     {
         try
         {
             if (!CanPurchase(cart.DistributorID, Country))
             {
                 Result.Result = RulesResult.Failure;
                 Result.AddMessage(
                     string.Format(
                         HttpContext.GetGlobalResourceObject(
                             string.Format("{0}_ErrorMessage", HLConfigManager.Platform),
                             "CountryOfProcessingOnly").ToString()));
                 cart.RuleResults.Add(Result);
             }
             else
             {
                 string key   = PaymentsConfiguration.GetPaymentInfoSessionKey(string.Empty, string.Empty);
                 var    items = Session[key] as List <CreditPayment>;
                 if (null != items)
                 {
                     int maxCards = HLConfigManager.Configurations.PaymentsConfiguration.MaxCardsToDisplay;
                     if (items.Count(p => (!string.IsNullOrEmpty(p.AuthorizationCode))) == maxCards)
                     {
                         if (reason == ShoppingCartRuleReason.CartItemsBeingRemoved)
                         {
                             cart.CurrentItems.Clear();
                         }
                         Result.Result = RulesResult.Failure;
                         Result.AddMessage(
                             string.Format(
                                 HttpContext.GetGlobalResourceObject(
                                     string.Format("{0}_ErrorMessage", HLConfigManager.Platform),
                                     "MustDeleteACardToChangeItemsInCart").ToString()));
                         cart.RuleResults.Add(Result);
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             LoggerHelper.Error(
                 string.Format(
                     "Error while performing Add or Delete from Cart Rule for Korean distributor: {0}, Cart Id:{1}, \r\n{2}",
                     cart.DistributorID, cart.ShoppingCartID, ex));
         }
     }
     return(Result);
 }
        /// <summary>Retrieves the current list of PaymentInformation from the users session</summary>
        /// <param name="locale">The current locale</param>
        /// <param name="distributorID">The current Distributor</param>
        /// <returns>The list of payments</returns>
        private List <CreditPayment> GetPaymentInformation()
        {
            string key   = PaymentsConfiguration.GetCurrentPaymentSessionKey(string.Empty, string.Empty);
            var    items = Session[key] as List <CreditPayment>;

            if (null == items)
            {
                SetPaymentInformation(null);
                items = _CurrentPaymentsList;
            }

            return(items.OrderBy(i => i.LineID).ToList());
        }
 public ConfigurationSet(System.Configuration.Configuration config)
 {
     _locale = config.AppSettings.Settings["Locale"].Value;
     _paymentsConfiguration         = PaymentsConfiguration.GetConfiguration(config);
     _addressingConfiguration       = AddressingConfiguration.GetConfiguration(config);
     _APFConfiguration              = APFConfiguration.GetConfiguration(config);
     _checkoutConfiguration         = CheckoutConfiguration.GetConfiguration(config);
     _DOConfiguration               = DOConfiguration.GetConfiguration(config);
     _paymentsConfiguration         = PaymentsConfiguration.GetConfiguration(config);
     _shoppingCartConfiguration     = ShoppingCartConfiguration.GetConfiguration(config);
     _rulesConfiguration            = RulesConfiguration.GetConfiguration(config);
     _pickupOrDeliveryConfiguration = PickupOrDeliveryConfiguration.GetConfiguration(config);
     ValidateState();
 }
Exemplo n.º 10
0
        protected void marketDropDownList_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            PaymentsConfiguration paymentsConfiguration = null;

            try
            {
                paymentsConfiguration = _paymentMethodDto.GetKlarnaPaymentsConfiguration(marketDropDownList.SelectedValue);
            }
            catch
            {
                paymentsConfiguration = new PaymentsConfiguration();
            }
            BindData(paymentsConfiguration);

            ConfigureUpdatePanelContentPanel.Update();
        }
Exemplo n.º 11
0
        public void SaveChanges(object dto)
        {
            if (!Visible)
            {
                return;
            }

            var paymentMethod = dto as PaymentMethodDto;

            if (paymentMethod == null)
            {
                return;
            }
            var currentMarket = marketDropDownList.SelectedValue;

            var configuration = new PaymentsConfiguration();

            configuration.MarketId = currentMarket;

            configuration.Username = txtUsername.Text;
            configuration.Password = txtPassword.Text;
            configuration.ApiUrl   = txtApiUrl.Text;

            configuration.LogoUrl                      = txtKlarnaLogoUrl.Text;
            configuration.WidgetDetailsColor           = txtColorDetails.Text;
            configuration.WidgetButtonColor            = txtColorButton.Text;
            configuration.WidgetButtonTextColor        = txtColorButtonText.Text;
            configuration.WidgetCheckboxColor          = txtColorCheckbox.Text;
            configuration.WidgetCheckboxCheckmarkColor = txtColorCheckboxCheckmark.Text;
            configuration.WidgetHeaderColor            = txtColorHeader.Text;
            configuration.WidgetLinkColor              = txtColorLink.Text;
            configuration.WidgetBorderColor            = txtColorBorder.Text;
            configuration.WidgetSelectedBorderColor    = txtColorBorderSelected.Text;
            configuration.WidgetTextColor              = txtColorText.Text;
            configuration.WidgetTextSecondaryColor     = txtColorTextSecondary.Text;
            configuration.WidgetBorderRadius           = txtRadiusBorder.Text;

            configuration.ConfirmationUrl             = txtConfirmationUrl.Text;
            configuration.NotificationUrl             = txtNotificationUrl.Text;
            configuration.SendProductAndImageUrlField = SendProductAndImageUrlCheckBox.Checked;
            configuration.UseAttachments        = UseAttachmentsCheckBox.Checked;
            configuration.CustomerPreAssessment = PreAssesmentCheckBox.Checked;
            configuration.AutoCapture           = AutoCaptureCheckBox.Checked;

            paymentMethod.SetParameter($"{currentMarket}_{Common.Constants.KlarnaSerializedMarketOptions}", Newtonsoft.Json.JsonConvert.SerializeObject(configuration));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string         key      = PaymentsConfiguration.GetCurrentPaymentSessionKey(this.Locale, this.DistributorID);
            List <Payment> payments = SessionInfo.GetSessionInfo(this.DistributorID, this.Locale).Payments;

            if (null == payments)
            {
                payments = Session[key] as List <Payment>;
            }
            if (null != payments && payments.Count > 0)
            {
                dlPaymentInfo.DataSource = payments;
                dlPaymentInfo.DataBind();
                CurrentPaymentInfo = payments;
            }
            SessionInfo.GetSessionInfo(this.DistributorID, this.Locale).Payments = null;
        }
        public void ReadPaymentProperties()
        {
            var paymentsConfiguration = new PaymentsConfiguration();
            var propertyInfos         = paymentsConfiguration.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (var propertyInfo in propertyInfos)
            {
                var customAttribute =
                    propertyInfo.GetCustomAttributes(typeof(ConfigurationPropertyAttribute), false)
                    .Cast <ConfigurationPropertyAttribute>().ToList();

                if (customAttribute.Any())
                {
                    var configurationProperty = customAttribute.Single();
                    var f = configurationProperty.Name;
                }
            }
        }
 protected override void OnInit(EventArgs e)
 {
     _locale                          = (Page as ProductsBase).Locale;
     _distributorId                   = (Page as ProductsBase).DistributorID;
     _paymentsConfig                  = HLConfigManager.Configurations.PaymentsConfiguration;
     _allowDecimal                    = _paymentsConfig.AllowDecimal;
     _allowWirePayment                = _paymentsConfig.AllowWirePayment;
     _allowDirectDepositPayment       = _paymentsConfig.AllowDirectDepositPayment;
     _allowWireForHardCash            = _paymentsConfig.AllowWireForHardCash;
     _cashOnly                        = (Page as ProductsBase).CashOnly();
     _hardCash                        = (Page as ProductsBase).HardCash;
     _allowCreditCardForHardCash      = _paymentsConfig.AllowCreditCardForHardCash;
     _allowMultipleCardsInTransaction = _paymentsConfig.AllowMultipleCardsInTransaction;
     _maxCardsToDisplay               = (_allowMultipleCardsInTransaction) ? _paymentsConfig.MaxCardsToDisplay : 1;
     _currencySymbol                  = HLConfigManager.Configurations.CheckoutConfiguration.CurrencySymbol;
     _paymentGatewayControl           = new PaymentInfo_Generic();
     _paymentGatewayControl.TheBase   = Page as ProductsBase;
     if (HLConfigManager.Configurations.CheckoutConfiguration.ConvertAmountDue)
     {
         _currencySymbol = HLConfigManager.Configurations.CheckoutConfiguration.Currency;
     }
 }
        public static List <PaymentInformation> GetFailedCards(List <FailedCardInfo> failedCards,
                                                               string distributorId,
                                                               string locale)
        {
            var results = new List <PaymentInformation>();

            if (failedCards.Count > 0)
            {
                var currentPayments =
                    HttpContext.Current.Session[PaymentsConfiguration.GetPaymentInfoSessionKey(distributorId, locale)]
                    as List <PaymentInformation>;
                if (null != currentPayments && currentPayments.Count > 0)
                {
                    results = (from cp in currentPayments
                               from f in failedCards
                               where
                               cp.CardNumber.Trim() == f.CardNumber.Trim() &&
                               cp.CardType.Trim() == f.CardType.Trim()
                               select cp).Distinct().ToList();
                }
            }
            return(results);
        }
Exemplo n.º 16
0
        public ActionResult AccountsBalance(AccountViewModel account)
        {
            AccountsBalanceHelper accountsBalanceHelper = new AccountsBalanceHelper();

            try
            {
                if (!ModelState.IsValid || !accountsBalanceHelper.ValidateAccountData(account))
                {
                    throw new Exception();
                }

                Session.Add("AccountDetails", account);
                //Session["PaymentProjNo"] = account.GroupID;
                //Session["ProjectName"] = account.GroupTitle;
                //Session["TotalDue"] = account.UserPayInfoList.Select(x => x.PaymentAmount).Sum();

                //var accountData = accountsBalanceHelper.GetAccountInfoForProject(account.GroupID);
                //var accList = account.UserPayInfoList.Select<AccountBalanceInfo, AccountDetailsForACH>(x => GetAccountDetailsForACH(x, account.GroupID)).ToList();
                //Session["AccountList"] = accList;
                //Session["accNumList"] = accList.Select(x => x.accountNumber).ToList();
                //Session["PaymentPayments"] = accList.Select(x => x.paymentamount).ToList();
                //Session["ArdaCollections"] = account.UserPayInfoList.Select(x => !x.IsARDAAmount && x.ARDAAmount > 0 ? "Y" : "").ToList();

                var context = new SitecoreContext();
                PaymentsConfiguration getContextItem = context.GetItem <PaymentsConfiguration>(PaymentsConfiguration.PaymentsConfigurationItem);

                var pathInfo = getContextItem?.PaymentsOptionPage?.Url;
                PaymentUtils.RedirectToPage(pathInfo);
                ModelState.Clear();
                return(null);
            }
            catch (Exception ex)
            {
                ModelState.Clear();
                return(AccountsBalance());
            }
        }
Exemplo n.º 17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack && this._paymentMethodDto != null && this._paymentMethodDto.PaymentMethodParameter != null)
            {
                var markets = _paymentMethodDto.PaymentMethod.FirstOrDefault().GetMarketPaymentMethodsRows();

                if (markets != null)
                {
                    PaymentsConfiguration paymentsConfiguration = null;
                    try
                    {
                        paymentsConfiguration = _paymentMethodDto.GetKlarnaPaymentsConfiguration(markets.FirstOrDefault().MarketId);
                    }
                    catch
                    {
                        paymentsConfiguration = new PaymentsConfiguration();
                    }
                    BindData(paymentsConfiguration);

                    marketDropDownList.DataSource = markets.Select(m => m.MarketId);
                    marketDropDownList.DataBind();
                }
            }
        }
        /// <summary>Retrieves the current list of PaymentInformation from the users session</summary>
        /// <param name="locale">The current locale</param>
        /// <param name="distributorID">The current Distributor</param>
        /// <returns>The list of payments</returns>
        public List <PaymentInformation> GetCurrentPaymentInformation(string locale, string distributorID)
        {
            string key = PaymentsConfiguration.GetCurrentPaymentSessionKey(string.Empty, string.Empty);

            return(Session[key] as List <PaymentInformation>);
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        public Session Build(Session session, ICart cart, PaymentsConfiguration paymentsConfiguration, IDictionary <string, object> dic = null, bool includePersonalInformation = false)
        {
            if (includePersonalInformation && paymentsConfiguration.CustomerPreAssessment)
            {
                session.Customer = new Customer
                {
                    DateOfBirth = "1980-01-01",
                    Gender      = "Male",
                    LastFourSsn = "1234"
                };
            }
            session.MerchantReference2 = "12345";

            if (paymentsConfiguration.UseAttachments)
            {
                var converter = new IsoDateTimeConverter
                {
                    DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"
                };


                var customerAccountInfos = new List <Dictionary <string, object> >
                {
                    new Dictionary <string, object>
                    {
                        { "unique_account_identifier", "Test Testperson" },
                        { "account_registration_date", DateTime.Now },
                        { "account_last_modified", DateTime.Now }
                    }
                };

                var emd = new Dictionary <string, object>
                {
                    { "customer_account_info", customerAccountInfos }
                };

                session.Attachment = new Attachment
                {
                    ContentType = "application/vnd.klarna.internal.emd-v2+json",
                    Body        = JsonConvert.SerializeObject(emd, converter)
                };
            }

            if (session.OrderLines != null)
            {
                foreach (var lineItem in session.OrderLines)
                {
                    if (lineItem.Type.Equals("physical"))
                    {
                        EntryContentBase entryContent = null;
                        FashionProduct   product      = null;
                        if (!string.IsNullOrEmpty(lineItem.Reference))
                        {
                            var contentLink = _referenceConverter.Service.GetContentLink(lineItem.Reference);
                            if (!ContentReference.IsNullOrEmpty(contentLink))
                            {
                                entryContent = _contentRepository.Service.Get <EntryContentBase>(contentLink);

                                var parentLink =
                                    entryContent.GetParentProducts(_relationRepository.Service).SingleOrDefault();
                                product = _contentRepository.Service.Get <FashionProduct>(parentLink);
                            }
                        }

                        var patchedOrderLine = (PatchedOrderLine)lineItem;
                        if (patchedOrderLine.ProductIdentifiers == null)
                        {
                            patchedOrderLine.ProductIdentifiers = new PatchedProductIdentifiers();
                        }

                        patchedOrderLine.ProductIdentifiers.Brand = product?.Brand;
                        patchedOrderLine.ProductIdentifiers.GlobalTradeItemNumber  = "GlobalTradeItemNumber test";
                        patchedOrderLine.ProductIdentifiers.ManuFacturerPartNumber = "ManuFacturerPartNumber test";
                        patchedOrderLine.ProductIdentifiers.CategoryPath           = "test / test";

                        if (paymentsConfiguration.SendProductAndImageUrlField && entryContent != null)
                        {
                            ((PatchedOrderLine)lineItem).ProductUrl = SiteUrlHelper.GetAbsoluteUrl() + entryContent.GetUrl(_linksRepository.Service,
                                                                                                                           _urlResolver.Service);
                        }
                    }
                }
            }
            return(session);
        }
        public override List <Payment> GetPayments(ServiceProvider.OrderSvc.Address_V01 shippingAddress)
        {
            var paymentList = new List <Payment>();

            CheckForPaymentGatewayResponse();
            var choice = GetCurrentPaymentOption();

            switch (choice)
            {
            case PaymentOptionChoice.DirectDeposit:
            case PaymentOptionChoice.WireTransfer:
            case PaymentOptionChoice.PaymentGateway:
            {
                paymentList.Add(CreateDummyPayment(shippingAddress));
                break;
            }

            case PaymentOptionChoice.CreditCard:
            {
                var paymentInfo = GetCurrentPaymentInformation(_locale, _distributorId);

                foreach (GridViewRow row in gridViewCardInfo.Rows)
                {
                    var cardType       = row.FindControl("lblCardType") as Label;
                    var lblIssueNumber = row.FindControl("lblIssueNumber") as TextBox;
                    var txtCVV         = row.FindControl("txtCVV") as TextBox;
                    var txtAmount      = row.FindControl("txtAmount") as TextBox;
                    var id             = row.FindControl("cardID") as TextBox;
                    var payOption      = row.FindControl("txtOption") as TextBox;
                    var choice1        = row.FindControl("txtChoice1") as TextBox;
                    var choice2        = row.FindControl("txtChoice2") as TextBox;
                    var ddInstallments = (DropDownList)row.FindControl("drpInstallments");
                    var currentOptions = row.FindControl("lnkPaymentOptions") as LinkButton;
                    int cardID         = int.Parse(id.Text);
                    var ddBCPoints     = row.FindControl("drpUsePoints") as DropDownList;

                    decimal cardAmount;
                    if (decimal.TryParse(txtAmount.Text, out cardAmount) && cardID > 0)
                    {
                        var info = paymentInfo.Find(p => p.ID == cardID);

                        var thePayment = new CreditPayment();
                        if (info.CardType.Trim() == "국민카드" || info.CardType.Trim() == "비씨카드")
                        {
                            var payment = new KoreaISPPayment_V01();
                            payment.Amount = cardAmount;
                            payment.AuthorizationMethod = AuthorizationMethodType.Online;
                            payment.Card = new CreditCard();
                            payment.Card.AccountNumber = info.CardNumber;
                            payment.Card.NameOnCard    = (info.CardHolder.First.Trim() + " " + info.CardHolder.Last.Trim()).Trim();
                            payment.Card.Expiration    = info.Expiration;
                            payment.Card.CVV           = txtCVV.Text.Trim();
                            payment.Currency           = HLConfigManager.Configurations.CheckoutConfiguration.Currency.Trim();
                            payment.Address            = (null != info.BillingAddress) ? info.BillingAddress : shippingAddress;
                            payment.BCTopPoints        = info.CardType.Trim() == "국민카드" ? int.Parse(ddBCPoints.SelectedValue) : 0;
                            var options = new PaymentOptions_V01();
                            options.NumberOfInstallments = int.Parse(ddInstallments.SelectedValue) + payment.BCTopPoints;
                            payment.PaymentOptions       = options;
                            payment.KvpEncryptedData     = info.IssueNumber;
                            payment.Card.IssuingBankID   = info.CardType;
                            payment.KvpSessionKey        = "FA";

                            thePayment = payment;
                        }
                        else
                        {
                            var payment = new KoreaMPIPayment_V01();
                            payment.Amount = cardAmount;
                            payment.AuthorizationMethod = AuthorizationMethodType.Online;
                            payment.Card = new CreditCard();
                            payment.Card.AccountNumber = info.CardNumber;
                            payment.Card.NameOnCard    = (info.CardHolder.First.Trim() + " " + info.CardHolder.Last.Trim()).Trim();
                            payment.Card.Expiration    = info.Expiration;
                            payment.Card.CVV           = txtCVV.Text.Trim();
                            payment.Currency           = HLConfigManager.Configurations.CheckoutConfiguration.Currency.Trim();
                            payment.Address            = (null != info.BillingAddress) ? info.BillingAddress : shippingAddress;
                            var options = new PaymentOptions_V01();
                            options.NumberOfInstallments = int.Parse(ddInstallments.SelectedValue);
                            payment.PaymentOptions       = options;
                            payment.CAVV = info.IssueNumber;
                            payment.Card.IssuingBankID = info.CardType;
                            payment.ECI = "";
                            payment.XID = "FA";

                            thePayment = payment;
                        }

                        thePayment.ReferenceID = currentOptions.Text;
                        paymentList.Add(thePayment);
                    }
                }
                break;
            }
            }

            string currentKey = PaymentsConfiguration.GetCurrentPaymentSessionKey(_locale, _distributorId);

            Session[currentKey] = paymentList;
            return(paymentList);
        }