コード例 #1
0
    public override void BindView()
    {
        if (this.CCPaymentMethodModel == null)
        {
            return;
        }

        this.CCNameOnCard.Text   = this.CCPaymentMethodModel.NameOnCard;
        this.CCNumber.Text       = this.CCPaymentMethodModel.CCNumber;
        this.CCSecurityCode.Text = this.CCPaymentMethodModel.CVV2;
        this.CCIssueNumber.Text  = this.CCPaymentMethodModel.CCIssueNumber;
        this.SetSelectedMonth();
        this.SetSelectedYear();
        this.HFCreditCardType.Value = this.CCPaymentMethodModel.CreditCardType != null ? this.CCPaymentMethodModel.CreditCardType.StoredCardType : string.Empty;
        this.SetCardTypeImageOpacity();

        IEnumerable <CreditCardType> cardTypes = this.CCPaymentMethodModel.AllowedCardTypes;

        ImageCardTypeVisa.Visible       = cardTypes.Any(f => f.CardType == CreditCardTypeEnum.Visa);
        ImageCardTypeMastercard.Visible = cardTypes.Any(f => f.CardType == CreditCardTypeEnum.MasterCard);
        ImageCardTypeAmex.Visible       = cardTypes.Any(f => f.CardType == CreditCardTypeEnum.AmericanExpress);
        ImageCardTypeDiscover.Visible   = cardTypes.Any(f => f.CardType == CreditCardTypeEnum.Discover);
        ImageCardTypeSolo.Visible       = cardTypes.Any(f => f.CardType == CreditCardTypeEnum.Solo);
        ImageCardTypeMaestro.Visible    = cardTypes.Any(f => f.CardType == CreditCardTypeEnum.Maestro);

        AspDotNetStorefrontGateways.Processors.AuthorizeNet authorizeNet = new AspDotNetStorefrontGateways.Processors.AuthorizeNet();
        RowSaveToWallet.Visible = authorizeNet.IsCimEnabled;

        if (cardTypes.Any(f => f.CardType == CreditCardTypeEnum.Solo) || cardTypes.Any(f => f.CardType == CreditCardTypeEnum.Maestro))
        {
            this.CCIssueNumberRow.Visible = true;
        }
        else
        {
            this.CCIssueNumberRow.Visible = false;
        }

        //Lets always enable the next button unless we have just pushed it.
        ButtonSaveCreditCardPaymentForm.Visible = !Model.HavePaymentData;

        RequiredFieldValidatorCCSecurityCode.Visible = !AspDotNetStorefrontCore.AppLogic.AppConfigBool("CardExtraCodeIsOptional");
        RequiredFieldValidatorCCSecurityCode.Enabled = !AspDotNetStorefrontCore.AppLogic.AppConfigBool("CardExtraCodeIsOptional");

        if (cardTypes.Any(f => f.CardType == CreditCardTypeEnum.Unknown))
        {
            PHCreditCardTypeDropDown.Visible = true;
            PHCreditCardTypeImages.Visible   = false;

            var customer = ((AspDotNetStorefront.SkinBase)Page).OPCCustomer;
            DDLCreditCardType.DataSource = AspDotNetStorefrontCore.CardTypeDataSource.GetAcceptedCreditCardTypes(customer).Select(f => f.ToUpper());
            DDLCreditCardType.DataBind();

            Vortx.OnePageCheckout.WebUtility.PageUtility.SetSelectedValue(DDLCreditCardType, this.CCPaymentMethodModel.CreditCardType.StoredCardType);
        }
        else
        {
            PHCreditCardTypeDropDown.Visible = false;
            PHCreditCardTypeImages.Visible   = true;
        }
    }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         AspDotNetStorefrontGateways.Processors.AuthorizeNet authorizeNet = new AspDotNetStorefrontGateways.Processors.AuthorizeNet();
         if (authorizeNet.IsCimEnabled)
         {
             BindPage();
         }
     }
 }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AspDotNetStorefrontGateways.Processors.AuthorizeNet authorizeNet = new AspDotNetStorefrontGateways.Processors.AuthorizeNet();
        if (authorizeNet.IsCimEnabled)
        {
            var customer = AspDotNetStorefrontCore.Customer.Current;
            this.WalletSelector1.Visible = customer.IsRegistered;
            this.WalletSelector1.PaymentProfileSelected += new CIM_WalletSelector.PaymentProfileSelectedHandler(WalletSelector1_PaymentProfileSelected);
        }

        //Make sure our paymentProfileId is preserved during postbacks but
        //gets cleared out when a user first enters the page
        if (!IsPostBack)
        {
            paymentProfileId = 0;
        }
    }
コード例 #4
0
    public void BindView()
    {
        if (this.CCPaymentMethodModel == null)
        {
            return;
        }

        this.CCNameOnCard.Text   = this.CCPaymentMethodModel.NameOnCard;
        this.CCNumber.Text       = this.CCPaymentMethodModel.CCNumber;
        this.CCSecurityCode.Text = this.CCPaymentMethodModel.CVV2;
        this.CCIssueNumber.Text  = this.CCPaymentMethodModel.CCIssueNumber;
        this.SetSelectedMonth();
        this.SetSelectedYear();
        this.HFCreditCardType.Value = this.CCPaymentMethodModel.CreditCardType.ToString();
        this.SetCardTypeImageOpacity();

        IEnumerable <CreditCardType> cardTypes = this.CCPaymentMethodModel.AllowedCardTypes;

        ImageCardTypeVisa.Visible       = cardTypes.Contains(CreditCardType.Visa);
        ImageCardTypeMastercard.Visible = cardTypes.Contains(CreditCardType.MasterCard);
        ImageCardTypeAmex.Visible       = cardTypes.Contains(CreditCardType.AmericanExpress);
        ImageCardTypeDiscover.Visible   = cardTypes.Contains(CreditCardType.Discover);
        ImageCardTypeSolo.Visible       = cardTypes.Contains(CreditCardType.Solo);
        ImageCardTypeMaestro.Visible    = cardTypes.Contains(CreditCardType.Maestro);

        AspDotNetStorefrontGateways.Processors.AuthorizeNet authorizeNet = new AspDotNetStorefrontGateways.Processors.AuthorizeNet();
        RowSaveToWallet.Visible = authorizeNet.IsCimEnabled;

        if (cardTypes.Contains(CreditCardType.Solo) || cardTypes.Contains(CreditCardType.Maestro))
        {
            this.CCIssueNumberRow.Visible = true;
        }
        else
        {
            this.CCIssueNumberRow.Visible = false;
        }

        //Lets always enable the next button unless we have just pushed it.
        //ButtonSaveCreditCardPaymentForm.Visible = !PaymentMethodModel.HavePaymentData;
    }
コード例 #5
0
    public override void SaveViewToModel()
    {
        Page.Validate("VGCreditCardPayment");

        if (!Page.IsValid)
        {
            // find the validator that failed, and if it's the CCNumber, then nuke the stored CCNumber
            foreach (BaseValidator validator in Page.Validators)
            {
                if (!validator.IsValid && (validator.ControlToValidate == CCNumber.ID))
                {
                    this.CCPaymentMethodModel.CCNumber = string.Empty;
                    this.CCPaymentMethodModel.Save();
                }
            }
            return;
        }

        CCNumber.Text = CCNumber.Text.Replace(" ", "").Replace("-", "");

        AspDotNetStorefrontGateways.Processors.AuthorizeNet authorizeNet = new AspDotNetStorefrontGateways.Processors.AuthorizeNet();
        if (authorizeNet.IsCimEnabled)
        {
            var customer = AspDotNetStorefrontCore.Customer.Current;
            if (CBSaveToAccount.Checked && paymentProfileId < 1)
            {
                string errorMsg, errorCode;

                string cardNumberToUse;
                if (CCNumber.Text.StartsWith("****"))
                {
                    cardNumberToUse = customer.PrimaryBillingAddress.CardNumber;
                }
                else
                {
                    cardNumberToUse = CCNumber.Text;
                }

                //set session var so that we don't try to create a new card multiple times
                paymentProfileId = GatewayAuthorizeNet.ProcessTools.SaveProfileAndPaymentProfile(customer.CustomerID, customer.EMail,
                                                                                                 AspDotNetStorefrontCore.AppLogic.AppConfig("StoreName"), paymentProfileId, customer.PrimaryBillingAddressID,
                                                                                                 cardNumberToUse, this.CCSecurityCode.Text, CCExpiresMonth.SelectedValue, CCExpiresYear.SelectedValue, out errorMsg, out errorCode);
                if (paymentProfileId <= 0 && errorCode != "E00039")
                {
                    ShowError(errorMsg);
                    return;
                }
            }
            if (!string.IsNullOrEmpty(customer.ThisCustomerSession["ActivePaymentProfileId"]))
            {
                long profileId = long.Parse(customer.ThisCustomerSession["ActivePaymentProfileId"]);
                var  profile   = GatewayAuthorizeNet.DataUtility.GetPaymentProfileWrapper(customer.CustomerID, customer.EMail, profileId);

                string profileCardType = profile.CardType == "AMEX" ? "AmericanExpress" : profile.CardType;

                this.CCPaymentMethodModel.CCMonth        = profile.ExpirationMonth;
                this.CCPaymentMethodModel.CCYear         = profile.ExpirationYear;
                this.CCPaymentMethodModel.CCNumber       = profile.CreditCardNumberMasked;
                this.CCPaymentMethodModel.CreditCardType = GetCardType(profileCardType);

                this.CCPaymentMethodModel.Save();

                return;
            }
        }

        this.CCPaymentMethodModel.NameOnCard    = this.CCNameOnCard.Text;
        this.CCPaymentMethodModel.CCMonth       = this.CCExpiresMonth.SelectedValue;
        this.CCPaymentMethodModel.CCYear        = this.CCExpiresYear.SelectedValue;
        this.CCPaymentMethodModel.CCIssueNumber = this.CCIssueNumber.Text;

        // Don't save out the number again if it has been hidden
        if (!this.CCNumber.Text.StartsWith("****"))
        {
            this.CCPaymentMethodModel.CCNumber = this.CCNumber.Text;
        }
        this.CCPaymentMethodModel.CVV2 = this.CCSecurityCode.Text;

        var selectedCardType = GetSelectedCardTypeFromForm();

        if (selectedCardType != null)
        {
            this.CCPaymentMethodModel.CreditCardType = selectedCardType;
        }

        this.CCPaymentMethodModel.Save();
    }
コード例 #6
0
    public override void Initialize()
    {
        PanelError.Visible = false;

        if (this.CCPaymentMethodModel == null)
        {
            return;
        }

        PopulateMonth();
        PopulateYear();

        PanelError.Visible = false;

        this.CCNameOnCard.Text = string.Empty;
        this.CCExpiresMonth.ClearSelection();
        this.CCExpiresYear.ClearSelection();
        this.CCNumber.Text          = string.Empty;
        this.CCSecurityCode.Text    = string.Empty;
        this.CCIssueNumber.Text     = string.Empty;
        this.HFCreditCardType.Value = string.Empty;

        string javascript = String.Format("javascript:setCreditCardType(event,'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}');",
                                          this.HFCreditCardType.ClientID,
                                          this.ImageCardTypeVisa.ClientID,
                                          this.ImageCardTypeMastercard.ClientID,
                                          this.ImageCardTypeDiscover.ClientID,
                                          this.ImageCardTypeAmex.ClientID,
                                          this.ImageCardTypeSolo.ClientID,
                                          this.ImageCardTypeMaestro.ClientID,
                                          this.CCIssueNumber.ClientID,
                                          this.CCSecurityCode.ClientID,
                                          this.CCNumber.ClientID);

        this.CCNumber.Attributes.Add("onkeydown", "javascript:captureKeyPress(event);");
        this.CCNumber.Attributes.Add("onkeyup", javascript);        //IE7/8 does not support oninput

        SetCardTypeImageOpacity();

        if (!PageUtility.IsAsyncPostBackForControl(this, ConfigurationProvider.DefaultProvider.ScriptManagerId))
        {
            PanelChooseWalletOrNewCard.Visible = false;

            AspDotNetStorefrontGateways.Processors.AuthorizeNet authorizeNet = new AspDotNetStorefrontGateways.Processors.AuthorizeNet();
            if (authorizeNet.IsCimEnabled)
            {
                if (this.Model.AccountModel.IsRegistered &&
                    GatewayAuthorizeNet.DataUtility.GetPaymentProfiles(Int32.Parse(this.Model.AccountModel.AccountId), this.Model.AccountModel.Email).Any())
                {
                    PanelChooseWalletOrNewCard.Visible = true;

                    PanelWallet.Visible        = WalletSelected;
                    PanelCreditDetails.Visible = !WalletSelected;

                    RadioButtonNewCard.Checked = !WalletSelected;
                    RadioButtonWallet.Checked  = WalletSelected;
                }
                else
                {
                    PanelCreditDetails.Visible = true;
                    RadioButtonNewCard.Checked = true;
                    PanelSelectWallet.Visible  = false;
                    RadioButtonWallet.Checked  = false;
                }
            }
        }
    }