在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):card-io/card.io-iOS-SDK开源软件地址(OpenSource Url):https://github.com/card-io/card.io-iOS-SDK开源编程语言(OpenSource Language):Objective-C 84.3%开源软件介绍(OpenSource Introduction):card.io SDK for iOScard.io provides fast, easy credit card scanning in mobile apps.
Stay up to datePlease keep your app up to date with the latest version of the SDK. All releases follow semantic versioning. To receive updates about new versions:
You can find and start technical discussions using the Stack Overflow card.io tag. Sample appFor a quick first look at card.io, we have included a very small sample application that you can build and run.
InstructionsThe card.io iOS SDK includes header files and a single static library. We'll walk you through integration and usage. Requirements
SetupCocoaPods, then add this line to your podfile:If you usepod 'CardIO' If you don't use CocoaPods, then:
With or without CocoaPods:
Sample codeYou can use card.io in two ways:
Integrate as a View ControllerCreate a class (most likely a subclass of // SomeViewController.h
#import "CardIO.h"
@interface SomeViewController : UIViewController<CardIOPaymentViewControllerDelegate>
// ... Make an optional call to speed up the subsequent launch of card.io scanning: // SomeViewController.m
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[CardIOUtilities preloadCardIO];
}
Start card.io card scanning: // SomeViewController.m
- (IBAction)scanCard:(id)sender {
CardIOPaymentViewController *scanViewController = [[CardIOPaymentViewController alloc] initWithPaymentDelegate:self];
[self presentViewController:scanViewController animated:YES completion:nil];
} Write delegate methods to receive the card info or a cancellation: // SomeViewController.m
- (void)userDidCancelPaymentViewController:(CardIOPaymentViewController *)scanViewController {
NSLog(@"User canceled payment info");
// Handle user cancellation here...
[scanViewController dismissViewControllerAnimated:YES completion:nil];
}
- (void)userDidProvideCreditCardInfo:(CardIOCreditCardInfo *)info inPaymentViewController:(CardIOPaymentViewController *)scanViewController {
// The full card number is available as info.cardNumber, but don't log that!
NSLog(@"Received card info. Number: %@, expiry: %02i/%i, cvv: %@.", info.redactedCardNumber, info.expiryMonth, info.expiryYear, info.cvv);
// Use the card info...
[scanViewController dismissViewControllerAnimated:YES completion:nil];
} Integrate as a ViewCardIOView is new as of card.io Version 3.3.0 (September 2013). We look forward to seeing how creative developers integrate it into their apps. If you do something cool with it, share it with @cardio! We also look forward to quickly resolving any issues that you may discover. Create a class (most likely a subclass of // SomeViewController.h
#import "CardIO.h"
@interface SomeViewController : UIViewController<CardIOViewDelegate>
// ... Using a CardIOView provides UI flexibility. Here are two sample integration options:
Option 1: Create a CardIOView when you need itConfirm that the user's device is capable of scanning cards: // SomeViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
if (![CardIOUtilities canReadCardWithCamera]) {
// Hide your "Scan Card" button, or take other appropriate action...
}
} Make an optional call to speed up the subsequent launch of card.io scanning: // SomeViewController.m
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[CardIOUtilities preloadCardIO];
}
Start card.io card scanning: // SomeViewController.m
- (IBAction)scanCard:(id)sender {
CardIOView *cardIOView = [[CardIOView alloc] initWithFrame:CGRECT_WITHIN_YOUR_VIEW];
cardIOView.delegate = self;
[self.view addSubview:cardIOView];
} Write the delegate method to receive the results: // SomeViewController.m
- (void)cardIOView:(CardIOView *)cardIOView didScanCard:(CardIOCreditCardInfo *)info {
if (info) {
// The full card number is available as info.cardNumber, but don't log that!
NSLog(@"Received card info. Number: %@, expiry: %02i/%i, cvv: %@.", info.redactedCardNumber, info.expiryMonth, info.expiryYear, info.cvv);
// Use the card info...
}
else {
NSLog(@"User cancelled payment info");
// Handle user cancellation here...
}
[cardIOView removeFromSuperview];
} Include a method to cancel card scanning: // SomeViewController.m
- (IBAction)cancelScanCard:(id)sender {
[cardIOView removeFromSuperview];
} Option 2: Include a hidden CardIOView in your viewMake an IBOutlet property: // SomeViewController.m
@interface SomeViewController ()
@property(nonatomic, strong, readwrite) IBOutlet CardIOView *cardIOView;
@end In your .xib, include a CardIOView, mark it as After confirming that the user's device is capable of scanning cards, set the // SomeViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
if (![CardIOUtilities canReadCardWithCamera]) {
// Hide your "Scan Card" button, remove the CardIOView from your view, and/or take other appropriate action...
} else {
self.cardIOView.delegate = self;
}
} Make an optional call to speed up the subsequent launch of card.io scanning: // SomeViewController.m
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[CardIOUtilities preloadCardIO];
}
Start card.io card scanning: // SomeViewController.m
- (IBAction)scanCard:(id)sender {
self.cardIOView.hidden = NO;
} Write the delegate method to receive the results: // SomeViewController.m
- (void)cardIOView:(CardIOView *)cardIOView didScanCard:(CardIOCreditCardInfo *)info {
if (info) {
// The full card number is available as info.cardNumber, but don't log that!
NSLog(@"Received card info. Number: %@, expiry: %02i/%i, cvv: %@.", info.redactedCardNumber, info.expiryMonth, info.expiryYear, info.cvv);
// Use the card info...
}
else {
NSLog(@"User canceled payment info");
// Handle user cancellation here...
}
cardIOView.hidden = YES;
} Include a method to cancel card scanning: // SomeViewController.m
- (IBAction)cancelScanCard:(id)sender {
self.cardIOView.hidden = YES;
} Hints & Tips
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论