iOS Integration

Accept payments in iPhone and iPad apps, with built-in support for Apple Pay. If you need help after reading this, check out our answers to common questions or chat live with other developers in #stripe on freenode.

The Stripe iOS SDK makes it easy to build an excellent payment experience in your iOS app. It provides powerful, customizable, UI elements to use out-of-the-box to collect your users' payment details.

We also expose the low-level APIs that power those elements to make it easy to build fully custom forms. This guide will take you all the way from integrating our SDK to accepting payments from your users via both credit cards and Apple Pay.

Install and configure the SDK

You can choose to install the Stripe iOS SDK via your favorite method. We support CocoaPods, Cathage, both static and dynamic frameworks, as well as Fabric.

  1. If you haven't already, install the latest version of CocoaPods.
  2. Add this line to your Podfile:
    pod 'Stripe'
  3. Run the following command:
    pod install
  4. Don't forget to use the .xcworkspace file to open your project in Xcode, instead of the .xcodeproj file, from here on out.
  5. In the future, to update to the latest version of the SDK, just run:
    pod update Stripe
  1. If you haven't already, install the latest version of Carthage.
  2. Add this line to your Cartfile:
    github "stripe/stripe-ios"
  3. Follow the Carthage installation instructions.
  4. In the future, to update to the latest version of the SDK, run the following command:
    carthage update stripe-ios --platform ios

The Stripe SDK is available from Twitter's Fabric platform. You can head over to Fabric.io to install their Mac app and follow their instructions from there.

Note: This is only compatible with iOS 8 and above.

  1. Head to our GitHub releases page and download and unzip Stripe.framework.zip.
  2. Drag Stripe.framework to the "Embedded Binaries" section of your Xcode project's "General" settings. Make sure to select "Copy items if needed".
  3. Head to the "Build Phases" section of your Xcode project settings, and create a new "Run Script Build Phase". Paste the following snippet into the text field:
    bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Stripe.framework/integrate-dynamic-framework.sh"
  4. In the future, to update to the latest version of our SDK, just repeat steps 1 and 2.

Note: We only recommend this approach if you need to support iOS 7 in your application.

  1. Head to our GitHub releases page and download and unzip StripeiOS-Static.zip.
  2. In Xcode, with your project open, click on "File" then "Add files to Project...".
  3. Select Stripe.framework in the directory you just unzipped.
  4. Make sure "Copy items if needed" is checked.
  5. Click "Add".
  6. In Xcode, click on "File", then "Add files to Project...".
  7. Select Stripe.bundle, located within Stripe.framework.
  8. Make sure "Copy items if needed" is checked.
  9. Click "Add".
  10. In the future, to update to the latest version of our SDK, just repeat steps 1-9.

Configure your Stripe integration in your App Delegate

After you're done installing the SDK, configure it with your Stripe API keys.

import UIKit
import Stripe

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        STPPaymentConfiguration.shared().publishableKey = "pk_test_6pRNASCoBOKtIshFeQd4XMUh"
        // do any other necessary launch configuration
        return true
    }
}
#import "AppDelegate.h"
@import Stripe;

@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[STPPaymentConfiguration sharedConfiguration] setPublishableKey:@"pk_test_6pRNASCoBOKtIshFeQd4XMUh"];
    // do any other necessary launch configuration
    return YES;
}
@end

Set up Apple Pay (optional)

Getting ready to accept Apple Pay in your app involves some (very quick) setup on the Apple Developer website, which we have as a separate guide to help get started. After you've obtained an Apple Merchant ID, set it in your configuration:

STPPaymentConfiguration.shared().appleMerchantIdentifier = "your apple merchant identifier"
[[STPPaymentConfiguration sharedConfiguration] setAppleMerchantIdentifier:@"your apple merchant identifier"];

Next steps

  • The simplest way to integrate our SDK is using STPPaymentContext, a class designed to make building your app's checkout flow as easy as possible. It handles collecting, saving, and reusing your user's payment details, and can also be used to collect shipping info. If you'd like to use STPPaymentContext, please read our Standard Integration Guide.
  • If you find that STPPaymentContext isn't flexible enough for your needs, you can use the individual components that it uses under the hood. For this, please refer to our Custom Integration Guide.