我正在使用Google Pay的isReadyToPay方法始终返回false。方法何时返回false或true? Google Pay是否已连接到语言环境?预先谢谢你!!!
mPaymentsClient = Wallet.getPaymentsClient(activity,
new Wallet.WalletOptions
.Builder()
.setEnvironment(WalletConstants.ENVIRONMENT_TEST)
.build());
IsReadyToPayRequest request = IsReadyToPayRequest.newBuilder()
.addAllowedPaymentMethod(WalletConstants.PAYMENT_METHOD_CARD)
.addAllowedPaymentMethod(WalletConstants.PAYMENT_METHOD_TOKENIZED_CARD)
.build();
Task<Boolean> task = mPaymentsClient.isReadyToPay(request);
task.addOnCompleteListener(
new OnCompleteListener<Boolean>() {
public void onComplete(Task<Boolean> task) {
try {
boolean result =
task.getResult(ApiException.class);
if (result == true) {
//show Google as payment option
} else {
//hide Google as payment option
}
} catch (ApiException exception) {
}
}
});
答案 0 :(得分:0)
您遵守了Google的所有要求吗?您是否已将这些行添加到AndroidManifest.xml中?
<meta-data
android:name="com.google.android.gms.wallet.api.enabled"
android:value="true" />