0

我使用 Google Pay isReadyToPay 方法总是返回 false。方法何时返回 false 或 true?Google Pay 是否与区域设置相关联?先谢谢了!!!

mPaymentsClient = Wallet.getPaymentsClient(activity,
                new Wallet.WalletOptions
                        .Builder()
                        .setEnvironment(WalletConstants.ENVIRONMENT_TEST)
                        .build());

    IsReadyToPayRequest request = IsReadyToPayRequest.newBuilder()
                    .addAllowedPaymentMethod(WalletConstants.PAYMENT_METHOD_CARD)
                    .addAllowedPaymentMethod(WalletConstants.PAYMENT_METHOD_TOKENIZED_CARD)
                    .build();
            Task<Boolean> task = mPaymentsClient.isReadyToPay(request);
            task.addOnCompleteListener(
                    new OnCompleteListener<Boolean>() {
                        public void onComplete(Task<Boolean> task) {
                            try {
                                boolean result =
                                        task.getResult(ApiException.class);
                                if (result == true) {
                                    //show Google as payment option
                                } else {
                                    //hide  Google as payment option
                                }
                            } catch (ApiException exception) {
                            }
                        }
                    });
4

1 回答 1

1

您是否遵守了 Google 的所有要求?您是否已将这些行添加到 AndroidManifest.xml 中?

<meta-data
android:name="com.google.android.gms.wallet.api.enabled"
android:value="true" />
于 2018-11-08T16:17:03.493 回答