Does Google Pay API have a method for checking if the user has already added a specific card into Google Pay? I know that there exists a method for checking if the user available make payments.
From official docs:
... call the isReadyToPay API to determine if the user can make payments with the Google Pay API.
private void possiblyShowGooglePayButton() {
final Optional<JSONObject> isReadyToPayJson = PaymentsUtil.getIsReadyToPayRequest();
if (!isReadyToPayJson.isPresent()) {
return;
}
IsReadyToPayRequest request = IsReadyToPayRequest.fromJson(isReadyToPayJson.get().toString());
if (request == null) {
return;
}
// The call to isReadyToPay is asynchronous and returns a Task. We need to provide an
// OnCompleteListener to be triggered when the result of the call is known.
Task<Boolean> task = mPaymentsClient.isReadyToPay(request);
task.addOnCompleteListener(this,
new OnCompleteListener<Boolean>() {
@Override
public void onComplete(@NonNull Task<Boolean> task) {
if (task.isSuccessful()) {
setGooglePayAvailable(task.getResult());
} else {
Log.w("isReadyToPay failed", task.getException());
}
}
});
}
But the code above 👆🏻 does not suites my needs. Maybe someone has a solution for that?
What do you mean by a specific card?
One thing that is easy to miss from the documentation existingPaymentMethodRequired
.
By default, the API checks whether or not the device/app can be used to make payments but passing the existingPaymentMethodRequired
option will check to see if they have existing payment methods that the user can use to make a payment.