gpt4 book ai didi

android - 当我将 existingPaymentMethodRequired 设置为 true 时,isReadyToPayRequest 返回 false

转载 作者:行者123 更新时间:2023-12-05 00:03:15 41 4
gpt4 key购买 nike

我按照此处的说明确定 Google Pay 钱包的准备情况。
https://developers.google.com/pay/api/android/guides/tutorial#isreadytopay
这工作正常,直到我设置 trueexistingPaymentMethodRequired .我的 Intent 是知道钱包是否至少有一张卡,但我总是得到 false从请求中。我的环境是测试环境,安卓手机注册了信用卡。有谁知道为什么?文档在这里 https://developers.google.com/pay/api/android/reference/request-objects#IsReadyToPayRequest

public static Optional<JSONObject> getIsReadyToPayRequest() {
try {
JSONObject isReadyToPayRequest = getBaseRequest();
isReadyToPayRequest.put(
"allowedPaymentMethods", new JSONArray().put(getBaseCardPaymentMethod()));
isReadyToPayRequest.put("existingPaymentMethodRequired", true);

return Optional.of(isReadyToPayRequest);

} catch (JSONException e) {
return Optional.empty();
}
}

private static JSONObject getCardPaymentMethod() throws JSONException {
JSONObject cardPaymentMethod = getBaseCardPaymentMethod();
cardPaymentMethod.put("tokenizationSpecification", getGatewayTokenizationSpecification());

return cardPaymentMethod;
}

private static JSONObject getBaseCardPaymentMethod() throws JSONException {
JSONObject cardPaymentMethod = new JSONObject();
cardPaymentMethod.put("type", "CARD");

JSONObject parameters = new JSONObject();
parameters.put("allowedAuthMethods", getAllowedCardAuthMethods());
parameters.put("allowedCardNetworks", getAllowedCardNetworks());
// Optionally, you can add billing address/phone number associated with a CARD payment method.
parameters.put("billingAddressRequired", true);

JSONObject billingAddressParameters = new JSONObject();
billingAddressParameters.put("format", "FULL");

parameters.put("billingAddressParameters", billingAddressParameters);

cardPaymentMethod.put("parameters", parameters);

return cardPaymentMethod;
}

private static JSONArray getAllowedCardAuthMethods() {
return new JSONArray()
.put("PAN_ONLY")
.put("CRYPTOGRAM_3DS");
}
private static JSONArray getAllowedCardNetworks() {
return new JSONArray()
.put("AMEX")
.put("DISCOVER")
.put("INTERAC")
.put("JCB")
.put("MASTERCARD")
.put("VISA");
}
private static JSONObject getBaseRequest() throws JSONException {
return new JSONObject().put("apiVersion", 2).put("apiVersionMinor", 0);
}


private void possiblyShowGooglePayButton() {

final Optional<JSONObject> isReadyToPayJson = PaymentsUtil.getIsReadyToPayRequest();
if (!isReadyToPayJson.isPresent()) {
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.
IsReadyToPayRequest request = IsReadyToPayRequest.fromJson(isReadyToPayJson.get().toString());
Task<Boolean> task = paymentsClient.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 , 在 TEST环境,它应该总是返回 true :

Note: In the TEST environment, if you set existingPaymentMethodRequired to true in an IsReadyToPay() request, the response always returns true.


你能确认它总是返回 false为你?也就是说,文档不正确?

关于android - 当我将 existingPaymentMethodRequired 设置为 true 时,isReadyToPayRequest 返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66725579/

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