Google Pay集成显示此付款选项在该应用中不再可用

时间:2018-10-01 21:07:13

标签: c# android xamarin.android android-pay google-pay

我正在研究Xamarin项目集成Google Pay。我得到了立即购买按钮,但是当我按下该按钮时,我收到以下消息:“此应用程序中不再提供该付款选项”

我正在使用Stripe作为支付网关,并使用测试环境。这是我正在使用的活动。它继承了FragmentActivity,并实现了GoogleApiClient.IConnectionCallbacks和GoogleApiClient.IOnConnectionFailedListener

 public void SetupWallet()
            {
                _walletFragment = SupportWalletFragment.NewInstance(WalletFragmentOptions.NewBuilder()
                    .SetEnvironment(WalletConstants.EnvironmentTest)
                     .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
                .SetPaymentMethodTokenizationParameters(
                    PaymentMethodTokenizationParameters.NewBuilder()
                        .SetPaymentMethodTokenizationType(PaymentMethodTokenizationType.PaymentGateway)
                        .AddParameter("gateway", "stripe")
                        .AddParameter("stripe:publishableKey", AppConfig.StripeApiKey)
                        .AddParameter("stripe:version", "2018-02-06")
                        .Build())
                    .SetMerchantName("My Name")
                    .SetPhoneNumberRequired(false)
                    .SetShippingAddressRequired(false)
                    .SetEstimatedTotalPrice("20.00")
                    .SetCurrencyCode("USD")
                    .Build();

                _walletFragment.Initialize(WalletFragmentInitParams.NewBuilder()
                    .SetMaskedWalletRequest(maskedWalletRequest)
                    .SetMaskedWalletRequestCode(LOAD_MASKED_WALLET_REQ_CODE)
                    .Build());

                SupportFragmentManager.BeginTransaction()
                    .Replace(Resource.Id.dynamic_wallet_button_fragment, _walletFragment).Commit();
            }




       protected override void OnStart()
        {
            base.OnStart();
            _googleApiClient.Connect();
        }

        protected override void OnStop()
        {
            base.OnStop();
            _googleApiClient.Disconnect();
        }

        private void CheckAndroidPayAvailable()
        {
            var result = WalletClass.Payments.IsReadyToPay(_googleApiClient);
            result.SetResultCallback(new AndroidPayCallback(_walletFragment));

        }

protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.google_play_activity);

            _googleApiClient = new GoogleApiClient.Builder(((MainActivity)Forms.Context).ApplicationContext)
               .AddConnectionCallbacks(this)
               .AddOnConnectionFailedListener(this)
               .AddApi(WalletClass.API, new WalletClass.WalletOptions.Builder()
                     .SetEnvironment(WalletConstants.EnvironmentTest)
                     .Build())
                     .EnableAutoManage(this, this)
               .Build();

            SetupWallet();
            CheckAndroidPayAvailable();
        }

0 个答案:

没有答案