问题
I'm using card.io ios sdk for credit card scanning.
Is it possible to get credit card type(ie, whether it is Amercan Express or Master or visa) using card.io?
What are all the other possible details from credit card that we can get using card.io?
回答1:
I have no experience of using card.io
.
But your question got me all curious about this API.
In github, I found it and in there, there is a file: CardIOCreditCardInfo.h
// Derived from cardNumber.
// When provided by card.io, cardType will not be CardIOCreditCardTypeUnrecognized or CardIOCreditCardTypeAmbiguous.
@property(nonatomic, assign, readonly) CardIOCreditCardType cardType;
Hope this helps. I am trying to learn this, if it doesnot help you please tell me.
回答2:
Try this:
CardIOCreditCardInfo *crediCard = [[CardIOCreditCardInfo alloc] init];
crediCard.cardNumber = @"CARD NUMBER";
imageView.image = [CardIOCreditCardInfo logoForCardType:[crediCard cardType]];
回答3:
Josh from card.io here. Take a look at the CardIOCreditCardInfo header. The cardType
is derived from the cardNumber
, and from there you can get localized display strings and logos.
In general, card.io keeps its integration docs to a minimum, just the core product, but exposes extra goodies in the headers.
回答4:
I don't know how @Punit's answer is Accepted.. User wants VISA as name, which I achieved with following:
where info
is object of CardIOCreditCardInfo
received from userDidProvideCreditCardInfo
which is CardIOPaymentViewControllerDelegate
's delegate method.
NSSTring *cardName = [CardIOCreditCardInfo displayStringForCardType:info.cardType usingLanguageOrLocale:@"en_US"];
Since it has public method not instance method
/// Convenience method which returns a card type string suitable for display (e.g. "Visa", "American Express", "JCB", "MasterCard", or "Discover").
/// Where appropriate, this string will be translated into the language specified.
/// @param cardType The card type.
/// @param languageOrLocale See CardIOPaymentViewController.h for a detailed explanation of languageOrLocale.
/// @return Card type string suitable for display.
+ (NSString *)displayStringForCardType:(CardIOCreditCardType)cardType usingLanguageOrLocale:(NSString *)languageOrLocale;
来源:https://stackoverflow.com/questions/17967889/is-it-possible-to-get-credit-card-type-using-card-io