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();
    }
Esempio n. 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);
            }
        }
    }
Esempio n. 3
0
    public void SetModel(IPaymentModel model)
    {
        this.PaymentModel = (IPaymentModel)model;
        foreach (var kvp in this.PaymentModel.PaymentMethods)
        {
            PaymentMethodBaseModel method = kvp.Value;
            switch (method.PaymentType)
            {
            case PaymentType.CreditCard:
            {
                CreditCardPaymentViewForm.StringResourceProvider = this.StringResourceProvider;
                CreditCardPaymentViewForm.SetModel(method);
            }; break;

            case PaymentType.SecureNet:
            {
                SecureNetPaymentView.StringResourceProvider = this.StringResourceProvider;
                SecureNetPaymentView.SetModel(method);

                SecureNetPaymentView.ExistingCreditCardSelected += (o, e) => CreditCardPaymentViewForm.Hide();
                SecureNetPaymentView.NewCreditCardSelected      += (o, e) => CreditCardPaymentViewForm.Show();

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

                    ((SecureNetPaymentModel)method).SwitchPaymentMethod();
                };
            } break;

            case PaymentType.CheckByMail:
            {
                CheckPaymentView.StringResourceProvider = this.StringResourceProvider;
                CheckPaymentView.SetModel(method);
            }; break;

            case PaymentType.RequestAQuote:
            {
                RequestQuoteView.StringResourceProvider = this.StringResourceProvider;
                RequestQuoteView.SetModel(method);
            }; break;

            case PaymentType.PurchaseOrder:
            {
                PurchaseOrderPaymentView.StringResourceProvider = this.StringResourceProvider;
                PurchaseOrderPaymentView.SetModel(method);
            }; break;

            case PaymentType.PayPal:
            {
                PayPalPaymentView.StringResourceProvider = this.StringResourceProvider;
                PayPalPaymentView.SetModel(method);
            }; break;

            case PaymentType.PayPalExpress:
            {
                PayPalExpressView.StringResourceProvider = this.StringResourceProvider;
                PayPalExpressView.SetModel(method);
            } break;

            case PaymentType.MicroPay:
            {
                MicroPayPaymentView.StringResourceProvider = this.StringResourceProvider;
                MicroPayPaymentView.SetModel(method);
            } break;

            case PaymentType.COD:
            {
                CodPaymentView.StringResourceProvider = this.StringResourceProvider;
                CodPaymentView.SetModel(method);
            } break;

            case PaymentType.CheckoutByAmazon:
            {
                CheckOutByAmazonPaymentView.StringResourceProvider = this.StringResourceProvider;
                CheckOutByAmazonPaymentView.SetModel(method);
            } break;

            case PaymentType.PayPalEmbeddedCheckout:
            {
                PayPalEmbeddedCheckoutPaymentView.StringResourceProvider = this.StringResourceProvider;
                PayPalEmbeddedCheckoutPaymentView.SetModel(method);
            } break;

            case PaymentType.MoneybookersQuickCheckout:
            {
                MoneybookersQuickCheckoutPaymentView.StringResourceProvider = this.StringResourceProvider;
                MoneybookersQuickCheckoutPaymentView.SetModel(method);
            } break;
            }
        }
    }