Пример #1
0
 private void TogglePayPalEmbeddedCheckoutForm(bool show)
 {
     if (show)
     {
         if (PayPalEmbeddedCheckoutPaymentView != null)
         {
             if (PayPalEmbeddedCheckoutPaymentView.PaymentMethodModel != null)
             {
                 PanelPayPalEmbeddedCheckout.Visible = true;
                 RadioPayPalEmbeddedCheckout.Visible = true;
                 RadioPayPalEmbeddedCheckout.Checked = true;
                 PayPalEmbeddedCheckoutPaymentView.Initialize();
                 PayPalEmbeddedCheckoutPaymentView.Show();
                 PayPalEmbeddedCheckoutPaymentView.BindView();
             }
         }
     }
     else
     {
         RadioPayPalEmbeddedCheckout.Checked = false;
         PayPalEmbeddedCheckoutPaymentView.Hide();
     }
 }
Пример #2
0
    private void HandlePayPalOptions(List <PaymentMethodBaseModel> payPalOptions)
    {
        PaymentMethodBaseModel method;
        bool payPalEnabled = false;

        if (payPalOptions.Any(ppo => ppo.PaymentType == PaymentType.PayPalEmbeddedCheckout))
        {
            payPalEnabled = true;
            method        = payPalOptions.FirstOrDefault(ppo => ppo.PaymentType == PaymentType.PayPalEmbeddedCheckout);
            PayPalEmbeddedCheckoutPaymentView.SetModel(method);
            PayPalEmbeddedCheckoutPaymentView.Initialize();
            PayPalEmbeddedCheckoutPaymentView.Hide();

            PanelPayPalEmbeddedCheckout.Visible = true;
            RadioPayPalEmbeddedCheckout.Visible = true;
            RadioPayPalEmbeddedCheckout.Enabled = true;
            RadioPayPalEmbeddedCheckout.Checked = false;

            if (PaymentModel.ActivePaymentMethod != null && (PaymentModel.ActivePaymentMethod.PaymentType == PaymentType.PayPalExpress || PaymentModel.ActivePaymentMethod.PaymentType == PaymentType.PayPal))
            {
                PaymentModel.SetActivePaymentMethod(method.MethodId);
            }
        }
        if (payPalOptions.Any(ppo => ppo.PaymentType == PaymentType.PayPalExpress) && !payPalEnabled)
        {
            payPalEnabled = true;
            method        = payPalOptions.FirstOrDefault(ppo => ppo.PaymentType == PaymentType.PayPalExpress);
            PanelPaypalExpressMethod.Visible = true;

            PayPalExpressView.SetModel(method);
            PayPalExpressView.Initialize();
            PayPalExpressView.Hide();

            RadioPayPalExpress.Visible = true;
            RadioPayPalExpress.Enabled = true;
            RadioPayPalExpress.Checked = false;

            if (PaymentModel.ActivePaymentMethod != null && (PaymentModel.ActivePaymentMethod.PaymentType == PaymentType.PayPalEmbeddedCheckout || PaymentModel.ActivePaymentMethod.PaymentType == PaymentType.PayPal))
            {
                PaymentModel.SetActivePaymentMethod(method.MethodId);
            }
        }
        if (payPalOptions.Any(ppo => ppo.PaymentType == PaymentType.PayPal) && !payPalEnabled)
        {
            payPalEnabled             = true;
            method                    = payPalOptions.FirstOrDefault(ppo => ppo.PaymentType == PaymentType.PayPal);
            PanelPayPalMethod.Visible = true;
            PayPalPaymentView.SetModel(method);
            PayPalPaymentView.Initialize();
            PayPalPaymentView.Hide();

            RadioPayPal.Visible = true;
            RadioPayPal.Enabled = true;
            RadioPayPal.Checked = false;

            if (PaymentModel.ActivePaymentMethod != null && (PaymentModel.ActivePaymentMethod.PaymentType == PaymentType.PayPalEmbeddedCheckout || PaymentModel.ActivePaymentMethod.PaymentType == PaymentType.PayPalExpress))
            {
                PaymentModel.SetActivePaymentMethod(method.MethodId);
            }
        }
    }