从 here 运行适用于 Android 的 Braintree 演示应用程序时,似乎可以在沙盒模式下的 Dropin-UI 中显示 Google Pay 选项。
但是,当尝试自己创建 Dropin-UI 时,我无法做到这一点,Dropin 只显示选项“Paypal”和“信用卡或借记卡”。
在查看文档时,我找不到自己的代码/配置中缺少的内容。
我将最新的依赖项添加到我的 build.gradle 中:
implementation 'com.braintreepayments.api:drop-in:5.0.1'
implementation 'com.braintreepayments.api:braintree:3.14.2'
implementation 'com.braintreepayments.api:google-payment:3.3.1'
implementation 'com.google.android.gms:play-services-wallet:18.1.2'
我修改了 AndroidManifest.xml 以包含以下部分:
<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true"/>
我使用 token 化 key 来创建 dropin-request,如下所示:
DropInRequest dropInRequest = new DropInRequest()
.clientToken("sandbox_...") //Tokenization key from the Control Panel
.googlePaymentRequest(getGooglePaymentRequest());
startActivityForResult(dropInRequest.getIntent(MainActivity.this), 4949);
我创建了这样的 GooglePaymentRequest:
private GooglePaymentRequest getGooglePaymentRequest() {
GooglePaymentRequest googlePaymentRequest = new GooglePaymentRequest()
.transactionInfo(TransactionInfo.newBuilder()
.setTotalPrice("1.00")
.setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL)
.setCurrencyCode("USD")
.build())
.billingAddressRequired(true);
return googlePaymentRequest;
}
我在 Sandbox 帐户的控制面板中启用了 Google Pay。
但不幸的是,结果仍然是这样:
我多次扫描了文档,但我不知道是什么原因导致的。
有人看到我错过了什么吗?
最诚挚的问候, 菲利克斯
最佳答案
经过几天的尝试,在错误的位置上查找原因,终于找到了:
请务必添加 <meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true"/>
到 AndroidManifest.xml 中的 application 标记,而不是 Activity。
关于android - 如何在 Braintree Dropin 中显示 "Google Pay"选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64575682/