android - Google Pay 无法与 Braintree SDK 配合使用

标签 android paypal braintree google-pay

我已经实现了 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);
        }

如果有帮助,我们将不胜感激。

最佳答案

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

您似乎正在尝试将不正确的 Google Pay 对象通过 Braintree 传递到您的 Drop-in UI 中,以实现独立的 Google Pay 集成。

如果您还没有这样做,您需要在 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中找到更多相关信息。 .

关于android - Google Pay 无法与 Braintree SDK 配合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51635500/

相关文章:

android - 发送 SOAP 请求

android - actionBar 下方的分隔符

Paypal 不计算折扣代码后的运费(大卡特尔)

angularjs - Braintree Dropin UI 无法与 Ionic Framework 一起使用,除非强制刷新

android - HostnameVerifier 接口(interface)的不安全实现 - Android

css - 如何修改 CSS 以使付款表格具有黑色背景?

java - 如何从 Hashmap<String String> 获取 ArrayList

android - 主键约束被破坏。值已存在 : 0

paypal - 在多卖家市场设置中跟踪 Paypal 付款

paypal - 接受没有账户的信用卡付款