我想只接受借记卡使用Google电子钱包付款,我没有找到任何有用的文章或解决方案。
以下是我遵循的代码示例:
private PaymentDataRequest createPaymentDataRequest() {
PaymentDataRequest.Builder request =
PaymentDataRequest.newBuilder()
.setTransactionInfo(
TransactionInfo.newBuilder()
.setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL)
.setTotalPrice("10.00")
.setCurrencyCode("USD")
.build())
.addAllowedPaymentMethod(WalletConstants.PAYMENT_METHOD_CARD)
.addAllowedPaymentMethod(WalletConstants.PAYMENT_METHOD_TOKENIZED_CARD)
.setCardRequirements(
CardRequirements.newBuilder()
.addAllowedCardNetworks(
Arrays.asList(
WalletConstants.CARD_NETWORK_AMEX,
WalletConstants.CARD_NETWORK_DISCOVER,
WalletConstants.CARD_NETWORK_VISA,
WalletConstants.CARD_NETWORK_MASTERCARD))
.setAllowPrepaidCards(false)
.build());
PaymentMethodTokenizationParameters params =
PaymentMethodTokenizationParameters.newBuilder()
.setPaymentMethodTokenizationType(
WalletConstants.PAYMENT_METHOD_TOKENIZATION_TYPE_PAYMENT_GATEWAY)
.addParameter("gateway", "xxxx")
.addParameter("gatewayMerchantId", "xxxxxxx")
.build();
request.setPaymentMethodTokenizationParameters(params);
return request.build();
}
任何建议都将受到高度赞赏。
提前致谢。
答案 0 :(得分:0)
目前无法过滤掉Google Pay API中的信用卡。
但是,您可以使用getCardClass()从意图中收到PaymentData
后检查卡片类型:
PaymentData paymentData = PaymentData.getFromIntent(intent);
if (paymentData.getCardInfo().getCardClass() != WalletConstants.CARD_CLASS_DEBIT) {
// show error to user
}