protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.token_payment);
            SetTitle(Resource.String.title_payment_token);
            cv2EntryView = FindViewById<CV2EntryView>(Resource.Id.cv2EntryView);

            SetHelpText(Resource.String.help_info, Resource.String.help_cv2_text);
            SetHelpText(Resource.String.help_postcode_title, Resource.String.help_postcode_text, Resource.Id.postCodeHelpButton);

            judoPaymentRef = Intent.GetStringExtra(JudoSDKManager.JUDO_PAYMENT_REF);

            judoAmount = decimal.Parse(Intent.GetStringExtra(JudoSDKManager.JUDO_AMOUNT));
            judoId = Intent.GetStringExtra(JudoSDKManager.JUDO_ID);
            judoCurrency = Intent.GetStringExtra(JudoSDKManager.JUDO_CURRENCY);
            judoCardToken = Intent.GetParcelableExtra(JudoSDKManager.JUDO_CARD_DETAILS).JavaCast<CardToken>();
            judoConsumer = Intent.GetParcelableExtra(JudoSDKManager.JUDO_CONSUMER).JavaCast<Consumer>();

            if (judoPaymentRef == null)
            {
                throw new ArgumentException("JUDO_PAYMENT_REF must be supplied");
            }
            if (judoConsumer == null)
            {
                throw new ArgumentException("JUDO_CONSUMER must be supplied");
            }
            if (judoAmount == null)
            {
                throw new ArgumentException("JUDO_AMOUNT must be supplied");
            } 
            if (judoId == null)
            {
                throw new ArgumentException("JUDO_ID must be supplied");
            }
            if (judoCurrency == null)
            {
                throw new ArgumentException("JUDO_CURRENCY must be supplied");
            }
            if (judoCardToken == null)
            {
                throw new ArgumentException("JUDO_CARD_DETAILS must be supplied");
            }

            cv2EntryView.SetCardDetails(judoCardToken);

            judoMetaData = Intent.GetParcelableExtra(JudoSDKManager.JUDO_META_DATA).JavaCast<MetaData>();

            var payButton = FindViewById<Button>(Resource.Id.payButton);

            payButton.Text = Resources.GetString(Resource.String.token_payment);
            payButton.Click += (sender, args) => TransactClickHandler(MakeTokenPayment);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.payment);
            Title = GetString(Resource.String.title_payment);
            cardEntryView = FindViewById<CardEntryView>(Resource.Id.cardEntryView);
            TextView hintTextView = FindViewById<TextView>(Resource.Id.hintTextView);
            cardEntryView.HintTextView = hintTextView;
            avsEntryView = FindViewById<AVSEntryView>(Resource.Id.avsEntryView);
            startDateEntryView = FindViewById<StartDateIssueNumberEntryView>(Resource.Id.startDateEntryView);

            cv2ExpiryHelpInfoButton = FindViewById<HelpButton>(Resource.Id.infoButtonID);
            cv2ExpiryHelpInfoButton.Visibility = ViewStates.Gone;

            SetHelpText(Resource.String.help_info, Resource.String.help_card_text);
            SetHelpText(Resource.String.help_postcode_title, Resource.String.help_postcode_text,
                Resource.Id.postCodeHelpButton);

            judoPaymentRef = Intent.GetStringExtra(JudoSDKManager.JUDO_PAYMENT_REF);
            judoConsumer = Intent.GetParcelableExtra(JudoSDKManager.JUDO_CONSUMER).JavaCast<Consumer>();

            judoAmount = decimal.Parse(Intent.GetStringExtra(JudoSDKManager.JUDO_AMOUNT));
            judoId = Intent.GetStringExtra(JudoSDKManager.JUDO_ID);
            judoCurrency = Intent.GetStringExtra(JudoSDKManager.JUDO_CURRENCY);

            if (judoPaymentRef == null)
            {
                throw new ArgumentException("JUDO_PAYMENT_REF must be supplied");
            }
            if (judoConsumer == null)
            {
                throw new ArgumentException("JUDO_CONSUMER must be supplied");
            }
            if (judoAmount == null)
            {
                throw new ArgumentException("JUDO_AMOUNT must be supplied");
            } 
            if (judoId == null)
            {
                throw new ArgumentException("JUDO_ID must be supplied");
            }
            if (judoCurrency == null)
            {
                throw new ArgumentException("JUDO_CURRENCY must be supplied");
            }

            judoMetaData = Intent.Extras.GetParcelable(JudoSDKManager.JUDO_META_DATA).JavaCast<MetaData>();

            var payButton = FindViewById<Button>(Resource.Id.payButton);

            payButton.Text = Resources.GetString(Resource.String.payment);

            payButton.Click += (sender, args) => TransactClickHandler(MakeCardPayment);

            cardEntryView.OnCreditCardEntered += cardNumber =>
            {
                cv2ExpiryHelpInfoButton.Visibility = ViewStates.Visible;
            };

            cardEntryView.OnExpireAndCV2Entered += (expiryDate, cv2) =>
            {
                string cardNumber = null;

                try
                {
                    cardNumber = cardEntryView.GetCardNumber();
                }
                catch (Exception e)
                {
                    Console.Error.Write(e.StackTrace);
                }

                if (ValidationHelper.IsStartDateRequiredForCardNumber(cardNumber) && JudoSDKManager.Configuration.IsMaestroEnabled)
                {
                    startDateEntryView.Visibility = ViewStates.Visible;
                    startDateEntryView.RequestFocus();
                    avsEntryView.InhibitFocusOnFirstShowOfCountrySpinner();
                }

                if (JudoSDKManager.Configuration.IsAVSEnabled && avsEntryView != null)
                {
                    avsEntryView.Visibility = ViewStates.Visible;
                }
            };

            cardEntryView.OnReturnToCreditCardNumberEntry += () =>
            {
                cv2ExpiryHelpInfoButton.Visibility = ViewStates.Gone;
            };
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.register_card);
            SetTitle(Resource.String.title_register_card);

            cardEntryView = FindViewById<CardEntryView>(Resource.Id.cardEntryView);
            TextView hintTextView = FindViewById<TextView>(Resource.Id.hintTextView);
            cardEntryView.HintTextView = hintTextView;
            aVsEntryView = FindViewById<AVSEntryView>(Resource.Id.avsEntryView);
            startDateEntryView = FindViewById<StartDateIssueNumberEntryView>(Resource.Id.startDateEntryView);

            cv2ExpiryHelpInfoButton = FindViewById<HelpButton>(Resource.Id.infoButtonID);

            addressLine1 = FindViewById<EditText>(Resource.Id.addressLine1);
            addressLine2 = FindViewById<EditText>(Resource.Id.addressLine2);
            addressLine3 = FindViewById<EditText>(Resource.Id.addressLine3);
            addressTown = FindViewById<EditText>(Resource.Id.addressTown);
            addressPostCode = FindViewById<EditText>(Resource.Id.addressPostCode);
            
            SetHelpText(Resource.String.help_info, Resource.String.help_card_text);
            SetHelpText(Resource.String.help_postcode_title, Resource.String.help_postcode_text, Resource.Id.postCodeHelpButton);

            judoConsumer = Intent.GetParcelableExtra(JudoSDKManager.JUDO_CONSUMER).JavaCast<Consumer>();

            if (judoConsumer == null)
            {
                throw new IllegalArgumentException("JUDO_CONSUMER must be supplied");
            }

            judoMetaData = Intent.GetBundleExtra(JudoSDKManager.JUDO_META_DATA);

            var payButton = FindViewById<Button>(Resource.Id.payButton);

            payButton.SetText(Resource.String.register_card);

            payButton.Click += (sender, args) => TransactClickHandler(RegisterCard);

            cardEntryView.OnCreditCardEntered += cardNumber =>
            {
                cv2ExpiryHelpInfoButton.Visibility = ViewStates.Visible;
            };

            cardEntryView.OnExpireAndCV2Entered += (expiryDate, cv2) =>
            {
                string cardNumber = null;
                try
                {
                    cardNumber = cardEntryView.GetCardNumber();
                }
                catch (InvalidDataException e)
                {
                    Log.Error(JudoSDKManager.DEBUG_TAG, e.StackTrace, e);
                }

                bool startDateFocus = false;
                if (ValidationHelper.IsStartDateRequiredForCardNumber(cardNumber) && JudoSDKManager.Configuration.IsMaestroEnabled)
                {
                    startDateEntryView.Visibility = ViewStates.Visible;
                    startDateEntryView.RequestFocus();
                    startDateFocus = true;
                    aVsEntryView.InhibitFocusOnFirstShowOfCountrySpinner();
                }

                if (JudoSDKManager.Configuration.IsAVSEnabled && aVsEntryView != null)
                {
                    aVsEntryView.Visibility = ViewStates.Visible;

                    if (!startDateFocus)
                    {
                        aVsEntryView.FocusPostCode();
                    }
                }
            };

            cardEntryView.OnReturnToCreditCardNumberEntry += () =>
            {
               cv2ExpiryHelpInfoButton.Visibility = ViewStates.Gone;
            };
        }