Git Product home page Git Product logo

stripe-ios's Introduction

Stripe iOS SDK

CocoaPods Carthage compatible License Platform

Tip

Want to chat live with Stripe engineers? Join us on our Discord server.

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.

Get started with our 📚 integration guides and example projects, or 📘 browse the SDK reference.

Updating to a newer version of the SDK? See our migration guide and changelog.

Table of contents

Features

Simplified security: We make it simple for you to collect sensitive data such as credit card numbers and remain PCI compliant. This means the sensitive data is sent directly to Stripe instead of passing through your server. For more information, see our integration security guide.

Apple Pay: StripeApplePay provides a seamless integration with Apple Pay.

SCA-ready: The SDK automatically performs native 3D Secure authentication if needed to comply with Strong Customer Authentication regulation in Europe.

Native UI: We provide native screens and elements to collect payment details. For example, PaymentSheet is a prebuilt UI that combines all the steps required to pay - collecting payment details, billing details, and confirming the payment - into a single sheet that displays on top of your app.

PaymentSheet

Stripe API: StripePayments provides low-level APIs 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 to validate your user’s input.

Card scanning: We support card scanning on iOS 13 and higher. See our Card scanning section.

App Clips: The StripeApplePay module provides a lightweight SDK for offering Apple Pay in an App Clip.

Localized: We support the following localizations: Bulgarian, Catalan, Chinese (Hong Kong), Chinese (Simplified), Chinese (Traditional), Croatian, Czech, Danish, Dutch, English (US), English (United Kingdom), Estonian, Filipino, Finnish, French, French (Canada), German, Greek, Hungarian, Indonesian, Italian, Japanese, Korean, Latvian, Lithuanian, Malay, Maltese, Norwegian Bokmål, Norwegian Nynorsk (Norway), Polish, Portuguese, Portuguese (Brazil), Romanian, Russian, Slovak, Slovenian, Spanish, Spanish (Latin America), Swedish, Turkish, Thai and Vietnamese.

Identity: Learn about our Stripe Identity iOS SDK to verify the identity of your users.

Recommended usage

If you're selling digital products or services that will be consumed within your app, (e.g. subscriptions, in-game currencies, game levels, access to premium content, or unlocking a full version), you must use Apple's in-app purchase APIs. See the App Store review guidelines for more information. For all other scenarios you can use this SDK to process payments via Stripe.

Privacy

The Stripe iOS SDK collects data to help us improve our products and prevent fraud. This data is never used for advertising and is not rented, sold, or given to advertisers. Our full privacy policy is available at https://stripe.com/privacy.

For help with Apple's App Privacy Details form in App Store Connect, visit Stripe iOS SDK Privacy Details.

Modules

Module Description Compressed Uncompressed
StripePaymentSheet Stripe's prebuilt payment UI. 2.7MB 6.3MB
Stripe Contains all the below frameworks, plus Issuing and Basic Integration. 2.3MB 5.1MB
StripeApplePay Apple Pay support, including STPApplePayContext. 0.4MB 1.0MB
StripePayments Bindings for the Stripe Payments API. 1.0MB 2.6MB
StripePaymentsUI Bindings for the Stripe Payments API, STPPaymentCardTextField, STPCardFormView, and other UI elements. 1.7MB 3.9MB

Releases

We support Cocoapods, Carthage, and Swift Package Manager.

If you link the library manually, use a version from our releases page and make sure to embed all of the required frameworks.

For the Stripe module, link the following frameworks:

  • Stripe.xcframework
  • Stripe3DS2.xcframework
  • StripeApplePay.xcframework
  • StripePayments.xcframework
  • StripePaymentsUI.xcframework
  • StripeCore.xcframework
  • StripeUICore.xcframework

For other modules, follow the instructions below:

If you're reading this on GitHub.com, please make sure you are looking at the tagged version that corresponds to the release you have installed. Otherwise, the instructions and example code may be mismatched with your copy.

Requirements

The Stripe iOS SDK requires Xcode 15 or later and is compatible with apps targeting iOS 13 or above. We support Catalyst on macOS 11 or later.

For iOS 12 support, please use v22.8.4. For iOS 11 support, please use v21.13.0. For iOS 10, please use v19.4.0. If you need to support iOS 9, use v17.0.2.

Getting started

Integration

Get started with our 📚 integration guides and example projects, or 📘 browse the SDK reference for fine-grained documentation of all the classes and methods in the SDK.

Examples

Card scanning

PaymentSheet offers built-in card scanning. To enable card scanning, you'll 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.

You can demo this feature in our PaymentSheet example app. When you run the example app on a device, you'll see a "Scan Card" button when adding a new card.

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.

Running tests

  1. Install Carthage 0.37 or later (if you have homebrew installed, brew install carthage)
  2. From the root of the repo, run bundle install && bundle exec fastlane stripeios_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.

To re-record snapshot tests, use the bundle exec ruby ci_scripts/snapshots.rb --record.

Migrating from older versions

See MIGRATING.md

Code style

We use swiftlint to enforce code style.

To install it, run brew install swiftlint

To lint your code before pushing you can run ci_scripts/lint_modified_files.sh

You can also add this script as a pre-push hook by running ln -s "$(pwd)/ci_scripts/lint_modified_files.sh" .git/hooks/pre-push && chmod +x .git/hooks/pre-push

To format modified files automatically, you can use ci_scripts/format_modified_files.sh and you can add it as a pre-commit hook using ln -s "$(pwd)/ci_scripts/format_modified_files.sh" .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit

Licenses

stripe-ios's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stripe-ios's Issues

Demo menu options are swapped

In the Test Card Picker:

If I select 'Select Test Working Card' it will fail.
If I select 'Select Test Failing Card', it will succeed.

Otherwise, seems like the example all makes sense..

-[STPCard last4] Crash

The -[STPCard last4] function will crash if the credit card number string is less than 4 characters. Notice that it assumes there are at least 4 characters in the number:

- (NSString *)last4
{
    if (last4)
        return last4;
    else if ([self number])
        return [number substringFromIndex:([number length] - 4)];
    else
        return nil;
}

If you create an STPCard object and don't provide a number, the number is set to @"" which causes this method to crash if called.

delegate of PKTextField

I need to know when the PKTextField is the firstResponder, I mean my VC need to be delegate of that PKTextField.

I need this because the keyboard hide that field.

What is the best way to do this?

Apple pay actionsheet's cancel button not working.

As I am integrating Apple pay and run the code on simulator I can see the apple pay screen but Apple pay screen's cancel button on right top not working. How it will work is there any method to write code for dismissing it? I have checked in the header file but there is no any method for cancel.

Thanks in advance.

Add -[STPCard isEqualToCard:]

I'd really like to see a -[STPCard isEqualToCard:](or -isEqual:) method so I can determine if the user has changed any of the information. This way I won't have to fetch a new token if nothing has been changed in the editing view (mine, not an STPView).

Linking problem

Hi, I have a small problem, when I add the files to the project, and build, I get a linking problem
Undefined symbols for architecture i386:
"OBJC_CLASS$_SenTestCase", referenced from:
OBJC_CLASS$_PKCardCVCTest in PKCardCVCTest-2CB8FE38AE5849A2.o
OBJC_CLASS$_PKCardExpiryTest in PKCardExpiryTest-694556B46B90D9AB.o
OBJC_CLASS$_PKCardNumberTest in PKCardNumberTest-5A481508CE80F9AD.o
OBJC_CLASS$_PKTest in PKTest-4B4AD35D317119AF.o
OBJC_CLASS$_STPCardTest in STPCardTest-CC12ABC160880A9E.o
OBJC_CLASS$_STPTokenTest in STPTokenTest-BD156A15C3782AA0.o
OBJC_CLASS$_StripeTests in StripeTest-EAA480E5E3A0DAAB.o
...
"OBJC_METACLASS$_SenTestCase", referenced from:
OBJC_METACLASS$_PKCardCVCTest in PKCardCVCTest-2CB8FE38AE5849A2.o
OBJC_METACLASS$_PKCardExpiryTest in PKCardExpiryTest-694556B46B90D9AB.o
OBJC_METACLASS$_PKCardNumberTest in PKCardNumberTest-5A481508CE80F9AD.o
OBJC_METACLASS$_PKTest in PKTest-4B4AD35D317119AF.o
OBJC_METACLASS$_STPCardTest in STPCardTest-CC12ABC160880A9E.o
OBJC_METACLASS$_STPTokenTest in STPTokenTest-BD156A15C3782AA0.o
OBJC_METACLASS$_StripeTests in StripeTest-EAA480E5E3A0DAAB.o
...
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

If I build the example,works fine, but when I add the files to the my project I get this. I tried different fixes from stack overflow but no luck.
Can you help?
Thanks

Card number validation methods not checking length for card type

STPCard's validation method validateNumber:error: does not validate against the length for the card type. For example, this method returns YES for the number 5115 9151 1591 51, which needs two more digits to be a valid MasterCard number, and YES for 1231 2312 312, which is an unknown card type.

I'm not sure if this is a "bug" or not, because I could see the rationale for being a bit more permissive in validation for unknown card types, but it seems like at least known credit card types should validate against their proper length, which the framework is not doing.

Is there a better way to get more restrictive and accurate validation on credit card numbers?

PaymentKit tests can't be run from stripe-ios

stripe-ios's tests mock the system date to 8/29/97. This causes PaymentKit tests involving 2-digit years to fail; tests like [CEXPIRY(@"03/20") year] return 1920 instead of 2020. This is because our two-digit date parsing looks at the current year to determine which century to use.

y2k

When entering CC info in STPView, backspace on date puts user in awkward state

Have experienced the following with a few users, using STPView (Stripe pod version 1.1.4):

  1. Enter full, correct CC#
  2. Enter one digit for month of date, then backspace
    ** Cursor is now behind the last character of the 16th digit
  3. From here, you cannot get back to the date, which is presumably what you were trying to do.

Only way to get back to date that I've found is to either delete the 16th char of the CC then re-type it, or to stop editing (implemented by whatever containing view controller is hosting the STPView).

Proposed change: deleting all date chars leaves the cursor in the date input field, rather than backing up behind the 16th CC digit.

Podfile dependency missing

The current .podspec file does not include the dependency for PaymentKit - even though STPView.h imports that file.

I assume it's an issue with the cocoapods not using the --recursive flag when importing the git repo.

Seems like you can just put the dependency in the .podfile to cover that case.

Fresh install with podfiles and brand new xcode project does not work for me because of missing PKView.h error.

Sample iOS7

The custom view in sample doesn't seem to work in iOS7.

see the screen below:
ios7

Opt-in to compile Apple Pay code

It seems that Apple will send you a nastygram via email if you submit an iOS8 app that uses the new bindings but doesn't have an Apple Pay entitlement because it references new PassKit symbols.* We should find a way to make sure these don't get compiled unless people actually want them.

  • Note: they'll still accept your app, just send you a warning email

Some Example files have target membership for the StripeiOS and iOSTest targets

Most users won't encounter duplicate symbols, however, it can happen. It triggered for me for MBProgressHud.m which was a dependency of a different library.

Error messages will appear similar to this:
duplicate symbol OBJC_METACLASS$_MBRoundProgressView in:

The fix is to uncheck those targets from each file.

You may need to update the podspec file as well. Something similar to

spec.exclude_files = "Example"

Provide user agent to each request

For now, we only provide X-Stripe-User-Agent. We should also provide the standard User-Agent with these information:

  • App Name/Version
  • Bindings Name/Version
  • Device Name/Version
  • OS Name/Version

There are 10 compiler warnings when building for iOS7

Hey guys,

I would like to use this for a new app I'm making, but the number of compiler warnings is concerning. Any chance you guys can clean it up?

I'll send a pull request if I get to them before you, but just thought you should be aware.

image

Passing STPTestPaymentAuthorizationViewController instance instead of a true PKPaymentAuthorizationViewController breaks bindings for Xamarin.iOS

Love the stripe library, in fact, I'm working on creating bindings for it so it can be used in Xamarin.iOS!

The problem I'm facing is that in 'Test' mode, you are passing the instance of STPTestPaymentAuthorizationViewController into the paymentAuthorizationViewController:didAuthorizePayment:completion: delegate call instead of an actual instance of PKPaymentAuthorizationViewController manifests into an issue for a strongly typed language like C#.

Since both PKPaymentAuthorizationViewController and STPTestPaymentAuthorizationViewController both derive from UIViewController, it's not possible in C# to cast the STP one to the PKPayment one. I understand that this trick is allowed in Obj-C and makes testing Stripe with Pay that much more clean and simple (and intuitive), however it's going to stop us in our tracks from using Stripe in Xamarin.iOS.

Would you be willing to re-evaluate how Stripe is implemented in this case? One alternative could be to create a special STPTestPKPaymentDelegate which mimics paymentAuthorizationViewController:didAuthorizePayment:completion: and to implement that protocol in your ViewController to handle test responses.

Appreciate any help! Thanks!

Card input UI does not become first responder by default

The stripe payment view UI will become first responder when adding as a subview to any view. Our payment UI has the credit card at the bottom of our form field, so it does not make sense to become first responder right away. We would like a way to present against becoming first responder upon init, and also a way to eventually make it first responder programmatically when we want it to be.

Nil values cause EXC_BAD_ACCESS

Passing NULL values for successHandler or errorHandler to createTokenWithCard:success:error: cause EXC_BAD_ACCESS

If card is NULL we get a proper exception. Should do the same for the blocks.

Functional tests break when run with xctool (and thus, Travis CI)

For some reason STPCardFunctionalTest causes xctool to crash (presumably due to spinning the run loop while waiting for API results to come back). This makes our tests fail in Travis CI which uses xctool by default. There are a few potential solutions to this:

  1. Disable functional tests in Travis (the solution I've taken for now). Non-optimal for obvious reasons.
  2. Rewrite the tests and get them to work somehow. This may become easier with Xcode 6 and it's asynchronous testing utilities, but it may be a little while before that's available in TravisCI (~October)?
  3. Use xcodebuild (and, ideally, xcpretty) instead of xctool in Travis. This for some reason hangs indefinitely when running tests, but we could probably get it to work.

PKView iOS 5 compatibility

[UIImage resizableImageWithCapInsets:resizingMode:] is not supported prior iOS 6.0. I recommend to adjust the image and cal l resizableImageWithCapInsets: instead.

Example App Doesn't Compile

Seriously guys, if you want me to use stripe at least make sure your Example app compiles:

16 issues including:

/Users/michaelkaye/Downloads/stripe-ios-master/Example/StripeExample/ViewController.m:27:55: No known class method for selector 'paymentControllerWithRequest:delegate:'

/Users/michaelkaye/Downloads/stripe-ios-master/Example/StripeExample/ViewController.m:47:44: Use of undeclared identifier 'PKPaymentAuthorizationStatusFailure'

Maybe I'm missing a dependency or something is wrong with the search headers but it should just work. I don't want to have to spend time trying to fix it.

Response gratefully received.

(Parse error 141.)

Hello! I´m iOS developer and get the next error: "Error: Uh oh, something went wrong (Code: 141, Version: 1.2.20)". I replace the keys in my cloud code and Xcode example project. Someone could help me?

STPView becomes first responder on a mere init

On merely allocating and initing an STPView, this eventually calls into -[PKView setup], which calls -[PKView stateCardNumber]. In here, there's a line of code that makes the PKView become first responder: [self.cardNumberField becomeFirstResponder];

This is really, really, really bad form. This means that merely allocating and initing an STPView causes iOS's software keyboard to pop up. Is there a better place to put this call to becomeFirstResponder?

Swift support

Can you add support for iOS's newest programming language - swift. It comes out in October and I would like to have it in my app when iOS 8 comes out.

Missing files error

I want to run this code So I download it But it is giving me an error that PKComponent.m is missing. And I open project and found that there is library PaymentKit is missing from downloaded file

Methods for Bank Account Information (Recipients)

Hi, would it be possible to have in a next version the same method as ceateTokenWithCard for the bank account informations (createTokenWithBankAccount ?) when a recipient fills in its bank account information to receive payments?

Any suggestions where to start writing such a method in the meantime?

Thx very much

ApplePay and iOS 7 crashing

By adding the Apple Pay portion are we unable to support iOS 7 devices? I realize the functionality isn't there, but I would like the app to not crash upon load for iOS 7 and I just case out the Apple Pay code.

When running on iOS 7 (Device & Simulator), always seeing:

dyld: Symbol not found: _PKPaymentNetworkAmex
  Referenced from: /Users/[username]/Library/Developer/CoreSimulator/Devices/55F95399-6F9B-4621-84B1-8DFBE2BA8A05/data/Applications/D040B2CD-16C9-4B55-B39B-7BC17B9A9BD3/[APP].app/APP
  Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/System/Library/Frameworks/PassKit.framework/PassKit
 in /Users/[username]/Library/Developer/CoreSimulator/Devices/55F95399-6F9B-4621-84B1-8DFBE2BA8A05/data/Applications/D040B2CD-16C9-4B55-B39B-7BC17B9A9BD3/APP.app/[APP]

Removing the STRIPE_ENABLE_APPLEPAY macro makes everything work.

SenTestingKit CocoaPod is Crashing iOS 7.0.x

We deployed our application last week 2 weeks ago to a small group of developers and everything was all good. Most of us are on iOS 7.1.x but 2 of our teammates are on iOS 7.0.6. After our deploy last night, users on iOS 7.0.6 started noticing a crash. Where the app would actually die before anything really happened.

SenTesting Crash

I went through all of our Pods and found that the only application with SenTesting required is Stripe. Doing some more digging, I noticed that the .podspec for Stripe also changed two days ago

1.0.2 - s.frameworks = 'Foundation', 'QuartzCore'
1.0.3 - s.frameworks = 'Foundation', 'QuartzCore', 'SenTestingKit'

I changed my Podfile to run 1.0.2 and everything is back to working.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.