Contact Us Log In


Resources and tips

Add In-Person Payments into Your App with CardFlight and Stripe

Today, CardFlight is announcing the launch of our private beta, allowing developers to easily integrate card-present payments into their own mobile applications. CardFlight offers an encrypted magnetic stripe reader and a simple SDK/API so that developers can safely and securely accept card present payments in their apps, with support for their existing merchant account.  CardFlight works with most iOS and Android devices.

In addition, to launching our private beta, we are announcing that we have partnered with Stripe to make it super easy to use your existing Stripe accounts in CardFlight-powered applications. Stripe’s Cristina Cordova said, “We’re proud to be working with CardFlight, as they share our developer-friendly approach to payments.  CardFlight provides tools to any Stripe user looking to incorporate in-person payments into their mobile apps, while still taking advantage of Stripe’s simple pricing and seamless setup.”

The CardFlight SDK is designed to be embedded within a developer’s own application.  With just a few lines of code to integrate, developers can ensure that the flow to take a payment matches the rest of their app’s functionality. Let’s have a look and see how easy it is to integrate the CardFlight SDK into an iOS app:

Step 1 – Setup your app with CardFlight

Import the ‘CardFlight.h’ file in any UIViewController or UIViewController subclass header file where you want to access the CardFlight user interface. You will also need to set the CardFlight delegate within the Controller.

#import "CardFlight.h"
@interface ViewController : UIViewController  {}


To access your CardFlight account you will need to set your Developer API key and the associated Merchant Account Token that you wish to connect to when making payments. The Developer API key and Merchant Account Token will be shown on your Developer Dashboard, after creating and adding an account (i.e. Stripe) to your profile. See here for details on adding a new or existing Stripe account to CardFlight.

[CardFlight setAPIToken:@"e9cb15260f08e738b782952895d4ba4f"]; [CardFlight setAccountToken:@"04ff8bf650afb268"]; 


Step 2 – Swipe a card

To Swipe a card, you first need to initiate the card reader ready to accept card swipes. The card reader will be on standby mode for the next 10 seconds to accept a card swipe. The reader will timeout after this time and would require the same function to be called again before performing a new card swipe.

[[CardFlight sharedInstance] beginSwipeWithDefaultDialog:YES];


Step 3 – Handle swipe response

Handling the swipe response will not actually perform the payment, rather it will return first name, last name, and last 4 digits as (if the swipe was a success), or an error message if not successful (timeout, incorrect swipe, hardware error etc.) This will allow the app to further process an order/checkout until the user is ready to finalize the payment.

-(void)swipeResponse:(NSData *)data andError:(NSError *)error { if (!error) { NSDictionary *myDict =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]; nameTextField.text = [myDict objectForKey:@"name"]; numberTextField.text = [myDict objectForKey:@"card number"]; expDateTextField.text = [NSString stringWithFormat:@"%@/%@", [myDict objectForKey:@"exp month"], [myDict objectForKey:@"exp year"]]; } else { //Error management goes here } }


Step 4 – Process the payment

To process a payment to your merchant account, include the final amount and display a custom dialog (or default), show that the payment has been processed.

[[CardFlight sharedInstance] processPaymentWithDefaultDialog:YES andAmount:priceTextField.text.floatValue];


That’s it! Your ready to start processing card-present payments within your mobile app.

Request Access to CardFlight to get started today!

We are in the process of final testing of our Android library too, so sign up and we will keep you posted of it’s launch.

Check out our API Documentation for further details on integrating with CardFlight.