private void InitPaymentForm() { Task.Run(async() => { var paymentMethods = await DemoBackend.GetPaymentMethods(amount); var cardPaymentMethod = paymentMethods.FirstOrDefault(x => x.Type == "scheme"); if (cardPaymentMethod == null) { RunOnUiThread(() => Snackbar.Make(layout, "Credit card payments not available!", Snackbar.LengthLong).Show()); return; } var cardConfigurationBuilder = new CardConfiguration.Builder(this, Config.PublicKey); cardConfigurationBuilder.SetEnvironment(Com.Adyen.Checkout.Core.Api.Environment.Europe); var cardConfiguration = cardConfigurationBuilder.Build(); RunOnUiThread(() => { try { var cardComponent = CardComponent.Provider.Get(this, cardPaymentMethod, cardConfiguration) as CardComponent; var cardView = new CardView(this) { Id = View.GenerateViewId() }; var cardLayout = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); cardLayout.AddRule(LayoutRules.AlignParentTop); cardView.Attach(cardComponent, this); layout.AddView(cardView, cardLayout); textViewLoading.Visibility = ViewStates.Gone; cardComponent.Observe(this, new PaymentComponentObserver { Changed = state => { var paymentMethod = state.Data.PaymentMethod as CardPaymentMethod; Android.Util.Log.Debug("ObserverImpl", $"Onchanged -- Valid: {state.IsValid}, {paymentMethod.Type}"); if (state.IsValid) { fab.Enabled = true; this.paymentMethod = paymentMethod; } else { fab.Enabled = false; } } }); } catch (System.Exception ex) { Android.Util.Log.Error("MainActivity", Throwable.FromException(ex), ex.Message); } }); }); }