Android Pay:com.google.android.gms.wallet.shared.BuyFlowConfig

时间:2016-08-11 05:13:29

标签: android stripe-payments android-pay

我遇到这个奇怪的问题,我无法在网上找到任何帮助。

我有BaseActivity我有以下代码:

@Override
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
    intent.putExtra(Constants.ARG_FROM_ACTIVITY, getClass().getName());
    super.startActivityForResult(intent, requestCode, options);
}

现在,我正在尝试将Android Pay集成到我的PaymentActivity中,如下所示:

private void showWallet() {
        WalletFragmentStyle walletFragmentStyle = new WalletFragmentStyle()
                .setBuyButtonText(WalletFragmentStyle.BuyButtonText.BUY_WITH)
                .setBuyButtonAppearance(WalletFragmentStyle.BuyButtonAppearance.ANDROID_PAY_LIGHT)
                .setBuyButtonWidth(WalletFragmentStyle.Dimension.MATCH_PARENT);

        WalletFragmentOptions walletFragmentOptions = WalletFragmentOptions.newBuilder()
                .setEnvironment(WalletConstants.ENVIRONMENT_TEST)
                .setFragmentStyle(walletFragmentStyle)
                .setTheme(WalletConstants.THEME_LIGHT)
                .setMode(WalletFragmentMode.BUY_BUTTON)
                .build();

        SupportWalletFragment supportWalletFragment = SupportWalletFragment.newInstance(walletFragmentOptions);

        MaskedWalletRequest maskedWalletRequest = MaskedWalletRequest.newBuilder()
                .setPaymentMethodTokenizationParameters(PaymentMethodTokenizationParameters.newBuilder()
                        .setPaymentMethodTokenizationType(PaymentMethodTokenizationType.PAYMENT_GATEWAY)
                        .addParameter("gateway", "stripe")
                        .addParameter("stripe:publishableKey", "<my-key>")
                        .addParameter("stripe:version", Stripe.VERSION)
                        .build())
                .setShippingAddressRequired(false)
                .setEstimatedTotalPrice("1.00")
                .setCurrencyCode("USD")
                .build();

        WalletFragmentInitParams initParams = WalletFragmentInitParams.newBuilder()
                .setMaskedWalletRequest(maskedWalletRequest)
                .setMaskedWalletRequestCode(MASKED_WALLET_REQUEST_CODE)
                .build();

        supportWalletFragment.initialize(initParams);

        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.container, supportWalletFragment, WALLET_FRAGMENT_TAG)
                .commit();
    }

但是,当我尝试运行上面的代码时,我遇到了以下崩溃:

android.os.BadParcelableException: 
ClassNotFoundException when unmarshalling: com.google.android.gms.wallet.shared.BuyFlowConfig
at android.os.Parcel.readParcelableCreator(Parcel.java:2432)
at android.os.Parcel.readParcelable(Parcel.java:2358)
at android.os.Parcel.readValue(Parcel.java:2264)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2614)
at android.os.BaseBundle.unparcel(BaseBundle.java:221)
at android.os.BaseBundle.putString(BaseBundle.java:430)
at android.content.Intent.putExtra(Intent.java:6394)
at com.test.BaseActivity.startActivityForResult(BaseActivity.java:122)
at android.support.v4.app.ActivityCompatJB.startActivityForResult(ActivityCompatJB.java:31)
at android.support.v4.app.ActivityCompat.startActivityForResult(ActivityCompat.java:163)
at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:948)
at android.support.v4.app.FragmentActivity$HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:1057)
at android.support.v4.app.Fragment.startActivityForResult(Fragment.java:947)
at android.support.v4.app.Fragment.startActivityForResult(Fragment.java:936)
at com.google.android.gms.dynamic.zzh.startActivityForResult(Unknown Source)
at com.google.android.gms.dynamic.zzc$zza.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:387)
at lvg.a(:com.google.android.gms:728)
at com.google.android.gms.wallet.dynamite.fragment.b.a(:com.google.android.gms:551)
at aaee.handleMessage(:com.google.android.gms:210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

崩溃行是我将intent.putExtra放入BaseActivity

的地方

奇怪的是,应用程序崩溃了,因为它无法解组com.google.android.gms.wallet.shared.BuyFlowConfig。但它失败了,因为我试图在我的BaseActivity中添加一个额外的intent?我很迷茫。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:0)

应用程序的活动可能会覆盖startActivityForResult并尝试修改Play服务API正在触发的Intent。当您尝试修改意图时,Android将尝试取消分发Bundle的内容,然后由于ClientLibrary中不存在此类,可能会发生此错误。