stripe-ios/README.md

61 lines
4.4 KiB
Markdown
Raw Normal View History

2014-12-22 13:21:34 +08:00
# Stripe iOS SDK
2015-07-03 01:59:20 +08:00
[![Travis](https://img.shields.io/travis/stripe/stripe-ios/master.svg?style=flat)](https://travis-ci.org/stripe/stripe-ios)
2015-01-06 10:38:35 +08:00
[![CocoaPods](https://img.shields.io/cocoapods/v/Stripe.svg?style=flat)](http://cocoapods.org/?q=author%3Astripe%20name%3Astripe)
2015-03-07 06:03:14 +08:00
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
2015-01-06 10:38:35 +08:00
[![CocoaPods](https://img.shields.io/cocoapods/l/Stripe.svg?style=flat)](https://github.com/stripe/stripe-ios/blob/master/LICENSE)
[![CocoaPods](https://img.shields.io/cocoapods/p/Stripe.svg?style=flat)](https://github.com/stripe/stripe-ios#)
2014-09-04 12:31:02 +08:00
2014-12-22 13:21:34 +08:00
The Stripe iOS SDK make it easy to collect your users' credit card details inside your iOS app. By creating [tokens](https://stripe.com/docs/api#tokens), Stripe handles the bulk of PCI compliance by preventing sensitive card data from hitting your server (for more, see [our article about PCI compliance](https://support.stripe.com/questions/do-i-need-to-be-pci-compliant-what-do-i-have-to-do)).
2015-11-13 01:08:25 +08:00
We also offer [seamless integration](https://stripe.com/apple-pay) with [Apple Pay](https://www.apple.com/apple-pay/) that will allow you to securely collect payments from your customers in a way that prevents them from having to re-enter their credit card information.
2014-12-22 13:21:34 +08:00
## Requirements
2016-10-05 02:20:57 +08:00
Our SDK is compatible with iOS apps supporting iOS 8.0 and above. It requires Xcode 8.0+ to build the source.
If you need iOS 7 or Xcode 7 compatibility, the last supported SDK release is version 8.0.7.
2014-12-22 13:21:34 +08:00
## Integration
2014-09-10 04:39:14 +08:00
We've written a [guide](https://stripe.com/docs/mobile/ios) that explains everything from installation, to creating payment tokens, to Apple Pay integration and more.
2013-03-21 02:55:15 +08:00
2016-05-02 23:31:38 +08:00
For more fine-grained information on all of the classes and methods in our SDK, consult our [full SDK reference](http://stripe.github.io/stripe-ios/docs/index.html).
2015-01-17 07:28:12 +08:00
## Example apps
2013-03-21 02:55:15 +08:00
2015-08-07 00:22:14 +08:00
There are 2 example apps included in the repository:
2017-03-04 06:10:15 +08:00
- Stripe iOS Example (Simple) shows an integration using our prebuilt UI components [Swift]
- Stripe iOS Example (Custom) shows how to use our low-level methods to accept payments using several different payment methods [Objective-C].
2012-11-15 11:50:42 +08:00
To build the example apps, you'll need to first run `./setup.sh`. Then, open `Stripe.xcworkspace` and choose the appropriate scheme.
2015-11-04 02:45:04 +08:00
2016-07-07 03:09:21 +08:00
### Getting started with the iOS example apps
2014-02-12 12:49:44 +08:00
2016-10-05 02:20:57 +08:00
Note: all the example apps require Xcode 8.0 to build and run.
2014-09-29 21:30:52 +08:00
2016-07-07 03:09:21 +08:00
Before you can run the apps, you need to provide them with your Stripe publishable key.
2014-09-09 23:44:43 +08:00
1. If you haven't already, sign up for a [Stripe account](https://dashboard.stripe.com/register) (it takes seconds). Then go to https://dashboard.stripe.com/account/apikeys.
2016-07-07 03:09:21 +08:00
2. Replace the `stripePublishableKey` constant in CheckoutViewController.swift (for the Simple app) or Constants.m (for the Custom app) with your Test Publishable Key.
2015-02-26 15:17:32 +08:00
3. Head to https://github.com/stripe/example-ios-backend and click "Deploy to Heroku" (you may have to sign up for a Heroku account as part of this process). Provide your Stripe test secret key for the STRIPE_TEST_SECRET_KEY field under 'Env'. Click "Deploy for Free".
2017-03-04 06:10:15 +08:00
4. Replace the `backendBaseURL` variable in the example iOS app with the app URL Heroku provides you with (e.g. "https://my-example-app.herokuapp.com")
2017-03-04 06:10:15 +08:00
After this is done, you can make test payments through the app and see them in your Stripe dashboard. Head to https://stripe.com/docs/testing#cards for a list of test card numbers.
## card.io
To add card scanning capabilities to our prebuilt UI components, you can simply [install card.io](https://github.com/card-io/card.io-iOS-SDK#setup) alongside our SDK. You'll also need to set `NSCameraUsageDescription` in your application's plist, and provide a reason for accessing the camera (e.g. "To scan cards").
2017-06-02 06:52:10 +08:00
To try this out, you can run `./install_cardio.rb`, which will download and install card.io in Stripe iOS Example (Simple). Now, when you run the example app on a device, you'll see a "Scan Card" button when adding a new card.
2014-09-09 23:44:43 +08:00
## Running the tests
2017-01-06 06:35:16 +08:00
1. Install Carthage (if you have homebrew installed, `brew install carthage`)
2017-03-04 06:10:15 +08:00
2. From the root of the repo, install test dependencies by running `carthage bootstrap --platform ios --configuration Release --no-use-binaries`
3. Open Stripe.xcworkspace
2017-05-25 07:24:29 +08:00
4. Choose the "StripeiOS" scheme with the iPhone 6, iOS 10.3 simulator (required for snapshot tests to pass)
2017-03-04 06:10:15 +08:00
5. Run Product -> Test
2015-08-07 00:22:14 +08:00
## Migrating from older versions
2014-12-26 09:49:08 +08:00
2015-08-07 00:22:14 +08:00
See `MIGRATING.md`