谷歌支付isReadyToPay方法返回false



我使用的是Google Pay isReadyToPay方法总是返回false。方法何时返回false或true?Google Pay是否连接到Locale?事先谢谢!!!

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) {
}
}
});

你遵守了谷歌的所有要求吗?你把这些行添加到AndroidManifest.xml中了吗?

<meta-data
android:name="com.google.android.gms.wallet.api.enabled"
android:value="true" />

最新更新