Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add card scanning support #1629

Merged
merged 5 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Example/Basic Integration/CheckoutViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class CheckoutViewController: UIViewController {
config.requiredShippingAddressFields = settings.requiredShippingAddressFields
config.shippingType = settings.shippingType
config.additionalPaymentOptions = settings.additionalPaymentOptions
config.cardScanningEnabled = true
self.country = settings.country
self.paymentCurrency = settings.currency

Expand Down
4 changes: 4 additions & 0 deletions Example/UI Examples/BrowseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class BrowseViewController: UITableViewController, STPAddCardViewControllerDeleg
present(navigationController, animated: true, completion: nil)
case .STPAddCardViewController:
let config = STPPaymentConfiguration()
config.cardScanningEnabled = true
let viewController = STPAddCardViewController(configuration: config, theme: theme)
viewController.apiClient = MockAPIClient()
viewController.delegate = self
Expand All @@ -101,6 +102,7 @@ class BrowseViewController: UITableViewController, STPAddCardViewControllerDeleg
present(navigationController, animated: true, completion: nil)
case .STPAddCardViewControllerWithAddress:
let config = STPPaymentConfiguration()
config.cardScanningEnabled = true
config.requiredBillingAddressFields = .full
let viewController = STPAddCardViewController(configuration: config, theme: theme)
viewController.apiClient = MockAPIClient()
Expand All @@ -113,6 +115,7 @@ class BrowseViewController: UITableViewController, STPAddCardViewControllerDeleg
config.additionalPaymentOptions = [.default, .FPX]
config.requiredBillingAddressFields = .none
config.appleMerchantIdentifier = "dummy-merchant-id"
config.cardScanningEnabled = true
let viewController = STPPaymentOptionsViewController(configuration: config,
theme: theme,
customerContext: self.customerContext,
Expand All @@ -126,6 +129,7 @@ class BrowseViewController: UITableViewController, STPAddCardViewControllerDeleg
config.additionalPaymentOptions = .default
config.requiredBillingAddressFields = .none
config.appleMerchantIdentifier = "dummy-merchant-id"
config.cardScanningEnabled = true
let viewController = STPPaymentOptionsViewController(configuration: config,
theme: theme,
customerContext: self.customerContext,
Expand Down
2 changes: 2 additions & 0 deletions Example/UI Examples/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>NSCameraUsageDescription</key>
<string>Granting access to your camera will allow you to scan payment cards.</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
Expand Down
1 change: 0 additions & 1 deletion LocalizationTester/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ - (void)tableView:(__unused UITableView *)tableView didSelectRowAtIndexPath:(__u
STPPaymentConfiguration *configuration = [[STPPaymentConfiguration alloc] init];
configuration.requiredBillingAddressFields = STPBillingAddressFieldsFull;
STPAddCardViewController *addCardVC = [[STPAddCardViewController alloc] initWithConfiguration:configuration theme:[STPTheme defaultTheme]];
addCardVC.alwaysShowScanCardButton = YES;
addCardVC.alwaysEnableDoneButton = YES;
addCardVC.delegate = self;
vc = addCardVC;
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Table of contents
* [Getting Started](#getting-started)
* [Integration](#integration)
* [Examples](#examples)
* [Card IO](#card-io)
* [Card scanning](#card-scanning-beta)
* [Contributing](#contributing)
* [Migrating](#migrating-from-older-versions)
<!--te-->
Expand Down Expand Up @@ -51,7 +51,7 @@ You can use these individually, or take all of the prebuilt UI in one flow by fo

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)

**Card Scanning**: We support card scanning capabilities using card.io. See our [Card IO](#card-io) section.
**Card scanning**: We support card scanning on iOS 13 and higher. See our [Card scanning](#card-scanning-beta) section.

## Releases

Expand Down Expand Up @@ -89,11 +89,13 @@ Check out [stripe-samples](https://github.com/stripe-samples/) for more, includi
- [Accepting a card payment](https://github.com/stripe-samples/card-payment-charges-api) (Charges API)


## Card IO
## Card scanning (Beta)

To add card scanning capabilities to our prebuilt UI components, [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").
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.

Demo this in our [Basic Integration example app](https://github.com/stripe/stripe-ios/tree/v19.4.0/Example/Basic&20Integration) by running `./install_cardio.rb`, which will download and install card.io in the project. Now, when you run the example app on a device, you'll see a "Scan Card" button when adding a new card.
Demo this in our [Basic Integration example app](https://github.com/stripe/stripe-ios/tree/v19.4.0/Example/Basic%20Integration). When you run the example app on a device, you'll see a "Scan Card" button when adding a new card.

This feature is currently in beta. Please file bugs on our [GitHub issues page](https://github.com/stripe/stripe-ios/issues).

## Contributing

Expand Down
Loading