Reputation: 131
I am using Google Pay isReadyToPay method always returns false. When does method returns false or true? Is Google Pay connected to the Locale? Thank you beforehand!!!
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) {
}
}
});
Upvotes: 0
Views: 1469
Reputation: 14622
Have you followed all the requirements from Google? Have you added these lines to the AndroidManifest.xml?
<meta-data
android:name="com.google.android.gms.wallet.api.enabled"
android:value="true" />
Upvotes: 1