stripe-ios/README.md

118 lines
8.8 KiB
Markdown
Raw Normal View History

2014-12-22 13:21:34 +08:00
# Stripe iOS SDK
2017-08-16 08:19:47 +08:00
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)
2019-11-09 05:03:08 +08:00
[![License](https://img.shields.io/cocoapods/l/Stripe.svg?style=flat)](https://github.com/stripe/stripe-ios/blob/master/LICENSE)
[![Platform](https://img.shields.io/cocoapods/p/Stripe.svg?style=flat)](https://github.com/stripe/stripe-ios#)
2014-09-04 12:31:02 +08:00
2021-02-26 05:38:17 +08:00
The Stripe iOS SDK makes it quick and easy to build an excellent payment experience in your iOS app. We provide powerful and customizable UI screens and elements that can be used out-of-the-box to collect your users' payment details. We also expose the low-level APIs that power those UIs so that you can build fully custom experiences.
2017-08-16 08:19:47 +08:00
2019-11-09 05:03:08 +08:00
Get started with our [📚 integration guides](https://stripe.com/docs/payments) and [example projects](#examples), or [📘 browse the SDK reference](https://stripe.dev/stripe-ios/docs/index.html).
2019-08-30 06:50:44 +08:00
> Updating to a newer version of the SDK? See our [migration guide](https://github.com/stripe/stripe-ios/blob/master/MIGRATING.md) and [changelog](https://github.com/stripe/stripe-ios/blob/master/CHANGELOG.md).
2017-08-16 08:19:47 +08:00
Table of contents
=================
2017-08-16 08:19:47 +08:00
<!--ts-->
* [Features](#features)
* [Releases](#releases)
* [Requirements](#requirements)
* [Getting Started](#getting-started)
* [Integration](#integration)
* [Examples](#examples)
2020-08-20 02:51:53 +08:00
* [Card scanning](#card-scanning-beta)
* [Contributing](#contributing)
* [Migrating](#migrating-from-older-versions)
<!--te-->
2019-08-30 06:50:44 +08:00
## Features
**Simplified Security**: We make it simple for you to collect sensitive data such as credit card numbers and remain [PCI compliant](https://stripe.com/docs/security#pci-dss-guidelines). This means the sensitive data is sent directly to Stripe instead of passing through your server. For more information, see our [Integration Security Guide](https://stripe.com/docs/security).
**Apple Pay**: We provide a [seamless integration with Apple Pay](https://stripe.com/docs/apple-pay).
2019-08-30 06:50:44 +08:00
**SCA-Ready**: The SDK automatically performs native [3D Secure authentication](https://stripe.com/docs/payments/3d-secure) if needed to comply with [Strong Customer Authentication](https://stripe.com/docs/strong-customer-authentication) regulation in Europe.
**Stripe API**: We provide [low-level APIs](https://stripe.dev/stripe-ios/docs/Classes/STPAPIClient.html) that correspond to objects and methods in the Stripe API. You can build your own entirely custom UI on top of this layer, while still taking advantage of utilities like [STPCardValidator](https://stripe.dev/stripe-ios/docs/Classes/STPCardValidator.html) to validate your users input.
**Native UI**: We provide native screens and elements to collect payment and shipping details. For example, [STPPaymentCardTextField](https://stripe.dev/stripe-ios/docs/Classes/STPPaymentCardTextField.html) is a UIView that collects and validates card details:
<p align="center">
2020-02-12 08:01:00 +08:00
<img src="https://raw.githubusercontent.com/stripe/stripe-ios/11d293baa9b753234816367a5bbdc4ac5ad04af6/card-field.gif" width="300" height="56" alt="STPPaymentCardTextField" align="center">
</p>
You can use these individually, or take all of the prebuilt UI in one flow by following the [Basic Integration guide](https://stripe.com/docs/mobile/ios/basic).
2019-08-30 06:50:44 +08:00
<p align="center">
2020-02-12 08:01:00 +08:00
<img src="https://raw.githubusercontent.com/stripe/stripe-ios/11d293baa9b753234816367a5bbdc4ac5ad04af6/add-card-vc.png" width="200" alt="STPAddCardViewController" hspace="20"><img src="https://raw.githubusercontent.com/stripe/stripe-ios/11d293baa9b753234816367a5bbdc4ac5ad04af6/payment-options.png" width="200" alt="STPPaymentOptionsViewController" hspace="20"><img src="https://raw.githubusercontent.com/stripe/stripe-ios/11d293baa9b753234816367a5bbdc4ac5ad04af6/shipping-address.png" width="200" alt="STPShippingAddressViewController" hspace="20">
2019-08-30 06:50:44 +08:00
</p>
From left to right: [STPAddCardViewController](https://stripe.dev/stripe-ios/docs/Classes/STPAddCardViewController.html), [STPPaymentOptionsViewController](https://stripe.dev/stripe-ios/docs/Classes/STPPaymentOptionsViewController.html), [STPShippingAddressViewController](https://stripe.dev/stripe-ios/docs/Classes/STPShippingAddressViewController.html)
2020-08-20 02:51:53 +08:00
**Card scanning**: We support card scanning on iOS 13 and higher. See our [Card scanning](#card-scanning-beta) section.
2017-06-30 05:14:18 +08:00
## Releases
2021-01-07 05:24:03 +08:00
We support Cocoapods, Carthage, and Swift Package Manager. If you link the library manually, use a version from our [releases](https://github.com/stripe/stripe-ios/releases) page. Make sure to embed both `Stripe.xcframework` and `Stripe3DS2.xcframework`.
If you're reading this on GitHub.com, please make sure you are looking at the [tagged version](https://github.com/stripe/stripe-ios/tags) that corresponds to the release you have installed. Otherwise, the instructions and example code may be mismatched with your copy. You can read the latest tagged version of this README and browse the associated code on GitHub using
2021-02-26 05:38:17 +08:00
[this link](https://github.com/stripe/stripe-ios/tree/21.3.1).
2014-12-22 13:21:34 +08:00
## Requirements
2016-10-05 02:20:57 +08:00
The Stripe iOS SDK requires Xcode 11 or later and is compatible with apps targeting iOS 11 or above. We support Catalyst on macOS 10.15 or later.
2020-09-12 09:22:41 +08:00
For iOS 10 support, please use [v19.4.0](https://github.com/stripe/stripe-ios/tree/v19.4.0). If you need to support iOS 9, use [v17.0.2](https://github.com/stripe/stripe-ios/tree/v17.0.2).
2014-12-22 13:21:34 +08:00
2017-08-16 08:19:47 +08:00
## Getting Started
2013-03-21 02:55:15 +08:00
2017-08-16 08:19:47 +08:00
### Integration
2016-05-02 23:31:38 +08:00
2019-11-09 05:03:08 +08:00
Get started with our [📚 integration guides](https://stripe.com/docs/payments) and [example projects](#examples), or [📘 browse the SDK reference](https://stripe.dev/stripe-ios/docs/index.html) for fine-grained documentation of all the classes and methods in the SDK.
2013-03-21 02:55:15 +08:00
2017-08-16 08:19:47 +08:00
### Examples
2012-11-15 11:50:42 +08:00
2017-08-16 08:19:47 +08:00
There are 3 example apps included in the repository:
2015-11-04 02:45:04 +08:00
2021-02-26 05:38:17 +08:00
- [UI Examples](https://github.com/stripe/stripe-ios/tree/21.3.1/Example/UI%20Examples).
- This example lets you quickly try out the SDK's prebuilt UI components using a mock backend—just build and run!
2021-02-26 05:38:17 +08:00
- [Basic Integration](https://github.com/stripe/stripe-ios/tree/21.3.1/Example/Basic%20Integration)
- This example demonstrates how to build a payment flow using our prebuilt UI component integration (`STPPaymentContext`).
2021-02-26 05:38:17 +08:00
- [Non-Card Payment Examples](https://github.com/stripe/stripe-ios/tree/21.3.1/Example/Non-Card%20Payment%20Examples)
- This example demonstrates how to use `STPAPIClient` to accept various non-card payment methods.
Check out [stripe-samples](https://github.com/stripe-samples/) for more, including:
- [Accepting a card payment](https://github.com/stripe-samples/accept-a-card-payment) (PaymentIntents API)
- [Saving a card without payment](https://github.com/stripe-samples/mobile-saving-card-without-payment) (SetupIntents API)
- [Accepting a card payment](https://github.com/stripe-samples/card-payment-charges-api) (Charges API)
2020-08-20 02:51:53 +08:00
## Card scanning (Beta)
2020-08-20 02:51:53 +08:00
To add card scanning capabilities to our prebuilt UI components, set the `cardScanningEnabled` option on your `STPPaymentConfiguration`. 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"). Card scanning is supported on devices with iOS 13 or higher.
2020-09-12 07:29:53 +08:00
<p align="center">
<img src="https://user-images.githubusercontent.com/52758633/92628867-4d040200-f282-11ea-95d2-023d9a461d25.gif" width="222" height="458" alt="Card Scanning Demo" align="center">
</p>
2021-02-26 05:38:17 +08:00
Demo this in our [Basic Integration example app](https://github.com/stripe/stripe-ios/tree/21.3.1/Example/Basic%20Integration). When you run the example app on a device, you'll see a "Scan Card" button when adding a new card.
2020-08-20 02:51:53 +08:00
This feature is currently in beta. Please file bugs on our [GitHub issues page](https://github.com/stripe/stripe-ios/issues).
2017-06-02 06:52:10 +08:00
2017-08-16 08:19:47 +08:00
## Contributing
We welcome contributions of any kind including new features, bug fixes, and documentation improvements. Please first open an issue describing what you want to build if it is a major change so that we can discuss how to move forward. Otherwise, go ahead and open a pull request for minor changes such as typo fixes and one liners.
2017-08-16 08:19:47 +08:00
### Running Tests
2021-02-19 05:25:48 +08:00
1. Install Carthage 0.37 or later (if you have homebrew installed, `brew install carthage`)
2021-03-12 09:31:32 +08:00
2. From the root of the repo, run `bundle install && bundle exec fastlane main_tests`. This will install the test dependencies and run the tests.
3. Once you have run this once, you can also run the tests in Xcode from the `StripeiOS` target in `Stripe.xcworkspace`. Make sure to use the iPhone 8, iOS 13.7 simulator so the snapshot tests will pass.
2017-08-16 08:19:47 +08:00
## Migrating from Older Versions
2014-12-26 09:49:08 +08:00
See [MIGRATING.md](https://github.com/stripe/stripe-ios/blob/master/MIGRATING.md)