问题描述
从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"/>
我像这样使用Tokenization密钥创建dropin请求:
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;
}
然后我在沙盒帐户的控制面板中启用了Google Pay。
但不幸的是,结果仍然是这样:
我多次扫描了文档,但看不到是什么原因造成的。
有人看到我想念的东西吗?
最好的问候, 费利克斯
解决方法
几天后,我一直试图在错误的位置上找到其原因,然后终于找到了它:
请确保将<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true"/>
添加到AndroidManifest.xml中的 application 标签中,而不要添加到活动中。