如何获取Android Pay的CardType /支付网络类型

时间:2016-06-20 17:58:23

标签: android android-pay

目前:

maskedWallet.getPaymentDescriptions()[0].substring(0,maskedWallet.getPaymentDescriptions()[0].indexOf("-")); 

会给我卡片类型(VISA / AMEX / MASTERCARD / DISCOVER)。 例如:maskedWallet.getPaymentDescriptions()[0]的字符串值为“VISA-1008”。

当找不到“ - ”时,上面的方法是抛出索引越界异常。

现在我已更新代码以从dpan(Android Pay给出的虚拟帐户#)获取付款网络类型/卡类型,使用相同的方法,根据信用卡号给我们卡类型(这里我使用了dpan而不是CC#)。

我想知道如果它是Android Pay交易,是否有更好的方式获得CardType?

1 个答案:

答案 0 :(得分:-1)

来自onActivityResults(){}

中收到的MaskedWallet对象
String card_type = mMaskedWallet.getInstrumentInfos()[0].getInstrumentType();
String card_num = mMaskedWallet.getInstrumentInfos()[0].getInstrumentDetails();

String cardholder_name =  mMaskedWallet.getBuyerBillingAddress().getName();

有关更多信息,请参阅文档: https://developers.google.com/android/reference/com/google/android/gms/wallet/MaskedWallet.html#getInstrumentInfos()