【问题标题】:Google Pay api Integration in adnroidandroid 中的 Google Pay api 集成
【发布时间】:2020-07-04 01:08:21
【问题描述】:

我已按照 Google 的官方文档进行 GPay 集成,即使我的 Google ID 中没有添加有效的支付卡,IsReadyToPayRequest 是否显示“TRUE”。我如何检查是否没有卡添加到 Google ID。请在下面找到我的代码:

    IsReadyToPayRequest request = IsReadyToPayRequest.fromJson(isReadyToPayJson.get().toString());
    Task<Boolean> task = paymentsClient.isReadyToPay(request);
    task.addOnCompleteListener((Activity) getContext(),
            new OnCompleteListener<Boolean>() {
                @Override
                public void onComplete(@NonNull Task<Boolean> task) {
                    if (task.isSuccessful()) {
                        showGooglePayButton(task.getResult());
                    } else {
                        Log.w("isReadyToPay failed", task.getException());
                    }
                }
            });

【问题讨论】:

  • 请分享您的getIsReadyToPayRequest() 功能。来自 PaymentUtils。
  • public static Optional getIsReadyToPayRequest() { try { JSONObject isReadyToPayRequest = getBaseRequest( ); isReadyToPayRequest.put("allowedPaymentMethods", new JSONArray().put(getBaseCardPaymentMethod())); isReadyToPayRequest.put("existingPaymentMethodRequired",true);返回 Optional.of(isReadyToPayRequest); } catch (JSONException e) { return Optional.empty( ); } }

标签: android api google-pay


【解决方案1】:

您需要传入existingPaymentMethodRequired,其值为true

见:https://developers.google.com/pay/api/android/reference/client#isReadyToPay

注意isReadyToPayexistingPaymentMethodRequiredTEST 环境中与PRODUCTION 的行为可能不同。也就是说,即使您没有可用的付款方式,isReadyToPay 的响应也可能会在 TEST 中返回 true

【讨论】:

  • 如果也没有添加卡,isReadyToPay 显示为 true。但是当我尝试按下继续按钮时,我在 AutoResolveHelper 上收到错误响应为 409!但在所有这些之前,我需要检查是否添加了卡?这可能吗?
  • IsReadyToPayRequest JSON 对象 : [ { "apiVersion": 2, "apiVersionMinor": 0, "allowedPaymentMethods": [ { "type": "CARD", "parameters": { "allowedAuthMethods": [ “PAN_ONLY”、“CRYPTOGRAM_3DS”]、
  • "allowedCardNetworks": ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA" ] } ], "existingPaymentMethodRequired": true } ]跨度>
  • 这是在TESTPRODUCTION 环境中吗?就像我上面提到的,existingPaymentMethodRequired 通常会在TEST 环境中返回true。让它在TEST 环境中返回false 的一种方法是仅将allowedAuthMethods 设置为["CRYPTOGRAM_3DS"]
  • 它在TEST environemnt!当我仅将 allowedAuthMethods 设置为 ["CRYPTOGRAM_3DS"] 时。 Gpay 按钮未显示并给出unfortunately, Google Pay is not available with this device 的祝酒消息。尽管我的设备上已经安装了 gpay。
猜你喜欢
  • 2020-03-20
  • 2018-07-03
  • 1970-01-01
  • 2021-11-26
  • 2016-05-06
  • 2021-05-20
  • 1970-01-01
  • 2019-12-26
  • 1970-01-01
相关资源
最近更新 更多