GooglePay无法与Braintree SDK配合使用

时间:2018-08-01 14:11:05

标签: 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);
        }

我们将不胜感激。

3 个答案:

答案 0 :(得分:0)

全部披露:我在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中找到有关此信息的更多信息。

答案 1 :(得分:0)

要在生产环境中使用Google Pay API,您还需要在Google方面为您的应用启用该功能。

他们的Integration checklist是一个很好的起点,特别是其中有一个叫做Requesting production access的部分

答案 2 :(得分:0)

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

PaymentDataRequest中的商人ID参数必须设置为您的Google Pay开发人员资料中提供的值。

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

相关问题