gpt4 book ai didi

android - Google Pay SDK 检查用户是否已添加特定卡

转载 作者:行者123 更新时间:2023-12-02 12:57:15 24 4
gpt4 key购买 nike

Google Pay API 是否有检查用户是否已将特定卡添加到 Google Pay 的方法?我知道有一种方法可以检查用户是否可以付款。

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());
}
}
});
}

但是上面的代码👆🏻不符合我的需求。也许有人对此有解决方案?

最佳答案

特定卡片是什么意思?

documentation 中很容易遗漏的一件事existingPaymentMethodRequired

默认情况下,API 会检查设备/应用程序是否可用于付款,但传递 existingPaymentMethodRequired 选项将检查它们是否具有用户可以使用的现有付款方式付款。

关于android - Google Pay SDK 检查用户是否已添加特定卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60074510/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com