Yar*_*nko 5 android kotlin google-pay
Google Pay API是否有方法检查用户是否已将特定卡添加到Google Pay中?我知道有一种方法可以检查用户是否可以付款。
来自官方文档:
...调用 isReadyToPay API 来确定用户是否可以使用 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());
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
但上面的代码不符合我的需求。也许有人有解决方案?
| 归档时间: |
|
| 查看次数: |
2402 次 |
| 最近记录: |