【问题标题】:GooglePay not working with Braintree SDKGoogle Pay 无法与 Braintree SDK 配合使用
【发布时间】:2019-01-09 03:44:18
【问题描述】:

我已经实现了 Braintree SDK,它支持使用 Paypal、信用卡或借记卡和 Google Pay 进行支付。

除 Google Pay 外,所有功能均正常运行。 选择付款方式为 GooglePay 时出现以下错误。

此商家未启用 Google Pay 即使我在 Braintree 控制台上启用了 Google Pay 选项。

以下是实现代码:

支付按钮点击代码:

DropInRequest dropInRequest = new DropInRequest()
                    .amount(strAmount)
                    .googlePaymentRequest(getGooglePaymentRequest())
                    .tokenizationKey("production_key_xxxxxxxxx");
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                startActivityForResult(dropInRequest.getIntent(getActivity()), 399);
            }



private GooglePaymentRequest getGooglePaymentRequest() {
            return new GooglePaymentRequest()
                    .transactionInfo(TransactionInfo.newBuilder()
                            .setTotalPrice(strAmount)
                            .setCurrencyCode("USD")
                            .setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL)
                            .build())
                    .emailRequired(true);
        }

我们将不胜感激。

【问题讨论】:

  • fstanis 的答案是正确的。不要忘记在 SANDBOX 模式下运行您的 Braintree 服务器端实现,否则他们无法测试它!这也是您收到上述消息的原因。对于测试,您需要 1)Braintree 网站:启用 GooglePay(沙盒)2)Braintree 服务器实现切换到 SANDBOX(不要忘记使用 SANDBOX 密钥)3)客户端实现:WalletConstants.ENVIRONMENT_TEST
  • 您找到解决方案了吗?为什么它不起作用?
  • 您在哪个环境中遇到问题?测试/沙盒还是生产?

标签: android paypal braintree google-pay


【解决方案1】:

全面披露:我在 Braintree 工作。如果您还有其他问题,请随时联系 support.

您似乎正试图通过 Braintree 将独立 Google Pay 集成的错误 Google Pay 对象传递到您的 Drop-in UI。

如果您还没有,则需要在您的AndroidManifest.xml 中包含 Google Pay 元标记:

<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true"/>

然后,构造一个GooglePaymentRequest 对象并将其传递给您的DropInRequest 对象。该对象可能类似于:

private void enableGooglePay(DropInRequest dropInRequest) {
    GooglePaymentRequest googlePaymentRequest = new GooglePaymentRequest()
      .transactionInfo(TransactionInfo.newBuilder()
        .setTotalPrice("1.00")
        .setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL)
        .setCurrencyCode("USD")
        .build())
      .billingAddressRequired(true); // We recommend collecting and passing billing address information with all Google Pay transactions as a best practice.

    dropInRequest.googlePaymentRequest(googlePaymentRequest);
}

您可以在our developer docs找到更多相关信息。

【讨论】:

    【解决方案2】:

    要在生产环境中使用 Google Pay API,您还需要在 Google 端为您的应用启用它。

    他们的Integration checklist 是一个很好的起点,特别是它有一个名为Requesting production access 的部分

    【讨论】:

      【解决方案3】:

      您还需要添加 googleMerchantId("YOUR-MERCHANT-ID")

      PaymentDataRequest 中的 MerchantId 参数必须设置为您的 Google Pay 开发者资料中提供的值。

      https://developers.google.com/pay/api/web/support/troubleshooting#merchantId

      【讨论】:

        猜你喜欢
        • 2018-06-25
        • 2018-12-13
        • 2020-09-03
        • 2018-07-02
        • 2021-09-02
        • 2015-09-19
        • 2021-02-06
        • 2018-09-30
        • 2016-05-06
        相关资源
        最近更新 更多