private PaymentMethodTokenizationParameters CreateTokenizationParameters() { try { var version = /*ListUtils.SettingsSiteList?.ScriptVersion ??*/ "2019-02-19"; return(PaymentMethodTokenizationParameters.NewBuilder() .SetPaymentMethodTokenizationType(WalletConstants.PaymentMethodTokenizationTypePaymentGateway) .AddParameter("gateway", "stripe") .AddParameter("stripe:publishableKey", PaymentConfiguration.Instance.PublishableKey) .AddParameter("stripe:version", version) .Build()); } catch (Exception exception) { Console.WriteLine(exception); return(null); } }
void CreateWalletFragment() { var walletStyle = new WalletFragmentStyle() .SetBuyButtonText(WalletFragmentStyle.BuyButtonText.LogoOnly) .SetBuyButtonAppearance(WalletFragmentStyle.BuyButtonAppearance.AndroidPayLightWithBorder) .SetBuyButtonWidth(WalletFragmentStyle.Dimension.MatchParent); var options = WalletFragmentOptions.NewBuilder() .SetEnvironment(WalletEnvironment) .SetTheme(WalletConstants.ThemeDark) .SetFragmentStyle(walletStyle) .SetMode(WalletFragmentMode.BuyButton) .Build(); var parameters = PaymentMethodTokenizationParameters.NewBuilder() .SetPaymentMethodTokenizationType(PaymentMethodTokenizationType.NetworkToken) .AddParameter("publicKey", Resources.GetString(Resource.String.public_key)) .Build(); _walletFragment = SupportWalletFragment.NewInstance(options); var walletRequest = Android.Gms.Wallet.MaskedWalletRequest.NewBuilder() .SetMerchantName(Resources.GetString(Resource.String.app_name)) .SetCurrencyCode(_judo.Currency) .SetEstimatedTotalPrice(_judo.Amount.ToString()) .SetPaymentMethodTokenizationParameters(parameters) .SetCart(Cart.NewBuilder() .SetCurrencyCode(_judo.Currency) .SetTotalPrice(_judo.Amount.ToString()) .Build()) .Build(); var startParams = WalletFragmentInitParams.NewBuilder() .SetMaskedWalletRequest(walletRequest) .SetMaskedWalletRequestCode(MaskedWalletRequest) .Build(); _walletFragment.Initialize(startParams); SupportFragmentManager.BeginTransaction() .Add(Resource.Id.container, _walletFragment) .Commit(); }
protected override void OnCreate(Android.OS.Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_checkout); mItemId = Intent.GetIntExtra(Constants.EXTRA_ITEM_ID, 0); createAndAddWalletFragment(); mReturnToShopping = FindViewById <Button> (Resource.Id.button_return_to_shopping); mReturnToShopping.Click += delegate { GoToItemListActivity(); }; mContinueCheckout = FindViewById <Button> (Resource.Id.button_regular_checkout); mContinueCheckout.Click += delegate { ContinueCheckout(); }; mStripeCheckbox = FindViewById <CheckBox> (Resource.Id.checkbox_stripe); mStripeCheckbox.CheckedChange += (sender, e) => { if (e.IsChecked && ValidateStripeConfiguration()) { mPaymentMethodParameters = PaymentMethodTokenizationParameters.NewBuilder() .SetPaymentMethodTokenizationType(PaymentMethodTokenizationType.PaymentGateway) .AddParameter("gateway", "stripe") .AddParameter("stripe:publishableKey", GetString(Resource.String.stripe_publishable_key)) .AddParameter("stripe:version", GetString(Resource.String.stripe_version)) .Build(); } else { mPaymentMethodParameters = null; } // Re-create the buy-button with the proper processor createAndAddWalletFragment(); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Create your application here SetContentView(Resource.Layout.Main); FindViewById <Button>(Resource.Id.buttonCard).Click += delegate { StartActivity(typeof(CardInputActivity)); }; var b = new WalletClass.WalletOptions.Builder() .SetEnvironment(WalletConstants.EnvironmentSandbox) .SetTheme(WalletConstants.ThemeLight) .Build(); googleApiClient = new GoogleApiClientBuilder(this) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .AddApi(WalletClass.API, b) .Build(); var walletFragment = SupportWalletFragment.NewInstance(WalletFragmentOptions.NewBuilder() .SetEnvironment(WalletConstants.EnvironmentSandbox) .SetMode(WalletFragmentMode.BuyButton) .SetTheme(WalletConstants.ThemeLight) .SetFragmentStyle(new WalletFragmentStyle() .SetBuyButtonText(BuyButtonText.BuyWithGoogle) .SetBuyButtonAppearance(BuyButtonAppearance.Classic) .SetBuyButtonWidth(Dimension.MatchParent)) .Build()); var maskedWalletRequest = MaskedWalletRequest.NewBuilder() // Request credit card tokenization with Stripe by specifying tokenization parameters: .SetPaymentMethodTokenizationParameters(PaymentMethodTokenizationParameters.NewBuilder() .SetPaymentMethodTokenizationType(PaymentMethodTokenizationType.PaymentGateway) .AddParameter("gateway", "stripe") .AddParameter("stripe:publishableKey", STRIPE_PUBLISHABLE_KEY) .AddParameter("stripe:version", "1.15.1") .Build()) // You want the shipping address: .SetShippingAddressRequired(true) .SetMerchantName("Llamanators") .SetPhoneNumberRequired(true) .SetShippingAddressRequired(true) // Price set as a decimal: .SetEstimatedTotalPrice("20.00") .SetCurrencyCode("USD") .Build(); // Set the parameters: var initParams = WalletFragmentInitParams.NewBuilder() .SetMaskedWalletRequest(maskedWalletRequest) .SetMaskedWalletRequestCode(LOAD_MASKED_WALLET_REQ_CODE) .Build(); // Initialize the fragment: walletFragment.Initialize(initParams); SupportFragmentManager.BeginTransaction().Replace(Resource.Id.frameFragment, walletFragment).Commit(); }