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