5.2 KiB
card.io SDK for iOS
card.io provides fast, easy credit card scanning in mobile apps.
Stay up to date
Get the latest SDK by downloading an archive of the most recent release.
Please keep your app up to date with the latest version of the SDK. All releases follow semantic versioning.
To receive updates about new versions:
- Follow @cardio (also great to send us feedback)
- Subscribe to our card-io-sdk-announce list
- "Watch" this GitHub repository
You can find and start technical discussions using the Stack Overflow card.io tag.
CocoaPods users: We strongly recommend that you include your Pods directory in source control, as for security reasons we may sometimes stop distributing old versions of the SDK. For details, see this discussion of the card.io SDK pod.
Sample app
For a quick first look at card.io, we have included a very small sample application that you can build and run.
- Get the latest SDK by downloading an archive of the most recent release.
- Simply open the
SampleAppfolder and follow the instructions in theREADME.mdfile you find there.
Instructions
The card.io iOS SDK includes header files and a single static library. We'll walk you through integration and usage.
Sign up for card.io
- To use the card.io SDK, you'll need to sign up and get an app token.
Requirements
- Supports target deployment of iOS version 6.1+ and instruction set armv7+ (including 64-bit).
Setup
- Get the latest SDK by downloading an archive of the most recent release.
- Add the CardIO directory (containing several .h files and libCardIO.a) to your Xcode project.
- In your project's Build Settings (in the
TARGETSsection, not thePROJECTSsection), add-lc++toOther Linker Flags. - Either:
- Add these frameworks to your project.
Weak linking is supported.
- AudioToolbox
- AVFoundation
- CoreGraphics
- CoreMedia
- CoreVideo
- Foundation
- MobileCoreServices
- OpenGLES
- QuartzCore
- Security
- UIKit
- or, if you are using Xcode 5 or newer:
- Add only this single framework to your project:
- AVFoundation (as an
Optional[i.e., weak-linked] library)
- AVFoundation (as an
- and confirm that these two Build Settings are both enabled:
Enable Modules (C and Objective-C)Link Frameworks Automatically
- Add card.io's open source license acknowledgments to your app's acknowledgments.
- Refer to the header files for more usage options and information.
Sample code
You can use card.io in two ways:
-
As a view controller: Quick and easy. Create a
CardIOPaymentViewControllerand present it modally. The card.io view controller handles all aspects of the UX, including manual entry as a fallback, all transitions, and number confirmation. -
As a view: More flexible. Create a
CardIOViewto do card scanning only and manage everything else yourself. This enables a broader range of presentations, such as in-place transitions, but requires that you handle the rest of the UI yourself.
Integrate as a View Controller
Create a class (most likely a subclass of UIViewController) that conforms to CardIOPaymentViewControllerDelegate.
// SomeViewController.h
#import "CardIO.h"
@interface SomeViewController : UIViewController<CardIOPaymentViewControllerDelegate>
// ...
Start card.io card scanning:
// SomeViewController.m
- (IBAction)scanCard:(id)sender {
CardIOPaymentViewController *scanViewController = [[CardIOPaymentViewController alloc] initWithPaymentDelegate:self];
scanViewController.appToken = @"YOUR_APP_TOKEN_HERE"; // get your app token from the card.io website
[self presentModalViewController:scanViewController animated:YES];
}
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 dismissModalViewControllerAnimated:YES];
}
- (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