private static MaskedWalletRequest CreateMaskedWalletRequest(ItemInfo itemInfo, PaymentMethodTokenizationParameters parameters)
        {
            // Build a List of all line items
            var lineItems = buildLineItems(itemInfo, true);

            // Calculate the cart total by iterating over the line items.
            var cartTotal = calculateCartTotal(lineItems);

            var builder = MaskedWalletRequest.NewBuilder()
                          .SetMerchantName(Constants.MERCHANT_NAME)
                          .SetPhoneNumberRequired(true)
                          .SetShippingAddressRequired(true)
                          .SetCurrencyCode(Constants.CURRENCY_CODE_USD)
                          .SetEstimatedTotalPrice(cartTotal)
                          // Create a Cart with the current line items. Provide all the information
                          // available up to this point with estimates for shipping and tax included.
                          .SetCart(Cart.NewBuilder()
                                   .SetCurrencyCode(Constants.CURRENCY_CODE_USD)
                                   .SetTotalPrice(cartTotal)
                                   .SetLineItems(lineItems)
                                   .Build());

            if (parameters != null)
            {
                builder.SetPaymentMethodTokenizationParameters(parameters);
            }

            return(builder.Build());
        }
예제 #2
0
        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();

            _walletFragment = SupportWalletFragment.NewInstance(options);

            var parameters = PaymentMethodTokenizationParameters.NewBuilder()
                             .SetPaymentMethodTokenizationType(WalletConstants.PaymentMethodTokenizationTypeNetworkToken)
                             .AddParameter("publicKey", Resources.GetString(Resource.String.public_key))
                             .Build();

            var walletRequest = 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(MaskedWalletRequestCode)
                              .Build();

            _walletFragment.Initialize(startParams);

            SupportFragmentManager.BeginTransaction()
            .Add(Resource.Id.container, _walletFragment)
            .Commit();
        }
예제 #3
0
        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();
        }