public override void SaveViewToModel()
 {
     if (AllowBillingAddressEdit())
     {
         BillingAddressChoice.SaveViewToModel();
     }
     if (this.PaymentMethodView != null)
     {
         if (this.Model.ActivePaymentMethod != null && this.Model.ActivePaymentMethod.PaymentType == PaymentType.CreditCard)
         {
             if (AspDotNetStorefrontCore.AppLogic.ActivePaymentGatewayCleaned() ==
                 AspDotNetStorefrontGateways.Gateway.ro_GWTWOCHECKOUT)
             {
                 TwoCheckoutPaymentView.SaveViewToModel();
                 return;
             }
             else if (AspDotNetStorefrontCore.AppLogic.ActivePaymentGatewayCleaned() ==
                      (new AspDotNetStorefrontGateways.Processors.Worldpay()).GatewayIdentifier)
             {
                 WorldPayPaymentView.SaveViewToModel();
                 return;
             }
             else if (AspDotNetStorefrontCore.AppLogic.ActivePaymentGatewayCleaned() == (new AspDotNetStorefrontGateways.Processors.SecureNetV4()).GatewayIdentifier)
             {
                 SecureNetPaymentView.SaveViewToModel();
             }
         }
         PaymentMethodView.SaveViewToModel();
     }
 }
 public override void Enable()
 {
     this.BillingAddressChoice.Enable();
     if (this.PaymentMethodView != null)
     {
         CreditCardPaymentForm.Enable();
         SecureNetPaymentView.Enable();
         TwoCheckoutPaymentView.Enable();
         CheckPaymentView.Enable();
         RequestQuoteView.Enable();
         PayPalPaymentView.Enable();
         PurchaseOrderPaymentView.Enable();
         PayPalExpressView.Enable();
         MicroPayPaymentView.Enable();
         CheckOutByAmazonPaymentView.Enable();
         PayPalEmbeddedCheckoutPaymentView.Enable();
         MoneybookersQuickCheckoutPaymentView.Enable();
         ECheckPaymentView.Enable();
         WorldPayPaymentView.Enable();
         if (IsFirstPay)
         {
             this.FirstPayPaymentForm.Enable();
         }
     }
 }
    public override void SetModel(IPaymentModel model, IStringResourceProvider stringResourceProvider)
    {
        base.SetModel(model, stringResourceProvider);

        this.BillingAddressChoice.SetModel(model.AccountModel, this.StringResourceProvider);

        CodPaymentView.SetModel(null, this.StringResourceProvider);
        CreditCardPaymentForm.SetModel(null, this.StringResourceProvider);
        SecureNetPaymentView.SetModel(null, this.StringResourceProvider);
        TwoCheckoutPaymentView.SetModel(null, this.StringResourceProvider);
        CheckPaymentView.SetModel(null, this.StringResourceProvider);
        RequestQuoteView.SetModel(null, this.StringResourceProvider);
        PayPalPaymentView.SetModel(null, this.StringResourceProvider);
        PurchaseOrderPaymentView.SetModel(null, this.StringResourceProvider);
        PayPalExpressView.SetModel(null, this.StringResourceProvider);
        MicroPayPaymentView.SetModel(null, this.StringResourceProvider);
        CheckOutByAmazonPaymentView.SetModel(null, this.StringResourceProvider);
        PayPalEmbeddedCheckoutPaymentView.SetModel(null, this.StringResourceProvider);
        MoneybookersQuickCheckoutPaymentView.SetModel(null, this.StringResourceProvider);
        ECheckPaymentView.SetModel(null, this.StringResourceProvider);
        WorldPayPaymentView.SetModel(null, this.StringResourceProvider);

        foreach (var paymentModel in this.Model.PaymentMethods)
        {
            var paymentView = FindPaymentMethodView(paymentModel.Key);
            if (paymentView != null)
            {
                paymentView.SetModel(paymentModel.Value, this.StringResourceProvider);
                ((IPaymentMethodView)paymentView).PaymentFormSubmitted += OPCControls_PaymentFormAndBillingAddress_PaymentFormSubmitted;
            }

            if (paymentModel.Value.PaymentType == PaymentType.SecureNet)
            {
                SecureNetPaymentView.ExistingCreditCardSelected += (o, e) => CreditCardPaymentForm.Hide();
                SecureNetPaymentView.NewCreditCardSelected      += (o, e) =>
                {
                    CreditCardPaymentForm.Initialize();
                    CreditCardPaymentForm.Show();
                    CreditCardPaymentForm.BindView();
                };

                Model.ProcessingPayment += (o, e) =>
                {
                    if (!(e.PaymentMethod is CreditCardPaymentModel) && !(e.PaymentMethod is SecureNetPaymentModel))
                    {
                        return;
                    }

                    ((SecureNetPaymentModel)paymentModel.Value).SwitchPaymentMethod();
                };
            }
        }

        this.ActivatePaymentView();
    }
    protected void BindPaymentView()
    {
        if (this.PaymentMethodView == null)
        {
            return;
        }

        bool showPaymentView = true;

        if (this.Model.ActivePaymentMethod != null && this.Model.ActivePaymentMethod.PaymentType == PaymentType.CreditCard)
        {
            if (AspDotNetStorefrontCore.AppLogic.ActivePaymentGatewayCleaned() ==
                AspDotNetStorefrontGateways.Gateway.ro_GWTWOCHECKOUT)
            {
                showPaymentView = false;

                TwoCheckoutPaymentView.Initialize();
                TwoCheckoutPaymentView.Show();
                TwoCheckoutPaymentView.BindView();
            }
            else if (AspDotNetStorefrontCore.AppLogic.ActivePaymentGatewayCleaned() ==
                     (new AspDotNetStorefrontGateways.Processors.Worldpay()).GatewayIdentifier)
            {
                showPaymentView = false;

                WorldPayPaymentView.Initialize();
                WorldPayPaymentView.Show();
                WorldPayPaymentView.BindView();
            }
            else
            {
                if (SecureNetPaymentView.IsVaultPaymentSelected)
                {
                    showPaymentView = false;
                }

                SecureNetPaymentView.Initialize();
                SecureNetPaymentView.Show();
                SecureNetPaymentView.BindView();
            }
        }

        if (showPaymentView)
        {
            this.PaymentMethodView.Initialize();
            this.PaymentMethodView.Show();
            this.PaymentMethodView.BindView();
        }
    }