目前:
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?
答案 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()