Google Pay SDK 检查用户是否已添加特定卡
Google Pay SDK check if user has already added specific card
Google Pay API 是否有检查用户是否已将特定卡添加到 [=22 的方法=]支付?我知道有一种方法可以检查用户是否可以付款。
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());
}
}
});
}
但是上面的代码不符合我的需要。也许有人对此有解决方案?
你所说的特定卡片是什么意思?
documentationexistingPaymentMethodRequired
.
中容易漏掉的一件事
默认情况下,API 检查 device/app 是否可用于付款,但通过 existingPaymentMethodRequired
选项将检查他们是否有现有的付款方式用户可以用来付款。
Google Pay API 是否有检查用户是否已将特定卡添加到 [=22 的方法=]支付?我知道有一种方法可以检查用户是否可以付款。
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());
}
}
});
}
但是上面的代码不符合我的需要。也许有人对此有解决方案?
你所说的特定卡片是什么意思?
documentationexistingPaymentMethodRequired
.
默认情况下,API 检查 device/app 是否可用于付款,但通过 existingPaymentMethodRequired
选项将检查他们是否有现有的付款方式用户可以用来付款。