- The
STPBackendAPIAdapter
protocol and all associated methods are no longer deprecated. We still recommend usingSTPCustomerContext
to update a Stripe customer object on your behalf, rather than using your own implementation ofSTPBackendAPIAdapter
.
- Changes to
STPCard
,STPCardParams
,STPBankAccount
, andSTPBankAccountParams
STPCard
no longer subclasses fromSTPCardParams
. You must now specifically createSTPCardParams
objects to create new tokens.STPBankAccount
no longer subclasses fromSTPBankAccountParams
.- You can no longer directly create
STPCard
objects, you should only use ones that have been decoded from Stripe API responses viaSTPAPIClient
. - All
STPCard
andSTPBankAccount
properties have been made readonly. - Broken out individual address properties on
STPCard
andSTPCardParams
have been deprecated in favor of the groupedaddress
property.
- The value of
[STPAPIResponseDecodable allResponseFields]
is now completely (deeply) filtered to not contain any instances of[NSNull null]
. Previously, only[NSNull null]
one level deep (shallow) were removed.
STPCustomer
'sshippingAddress
property is now correctly annotated as nullable. Its type is an optional (STPAddress?
) in Swift.
- We've greatly simplified the integration for
STPPaymentContext
. In order to migrate to the newSTPPaymentContext
integration using ephemeral keys, you'll need to:- On your backend, add a new endpoint that creates an ephemeral key for the Stripe customer associated with your user, and returns its raw JSON. Note that you should not remove the 3 endpoints you added for your initial PaymentContext integration until you're ready to drop support for previous versions of your app.
- In your app, make your API client class conform to
STPEphemeralKeyProvider
by adding a method that requests an ephemeral key from the endpoint you added in (1). - In your app, remove any references to
STPBackendAPIAdapter
. Your API client class will no longer need to conform toSTPBackendAPIAdapter
, and you can delete theretrieveCustomer
,attachSourceToCustomer
, andselectDefaultCustomerSource
methods. - Instead of using the initializers for
STPPaymentContext
orSTPPaymentMethodsViewController
that take anSTPBackendAPIAdapter
parameter, you should use the new initializers that take anSTPCustomerContext
parameter. You'll need to set up your instance ofSTPCustomerContext
using the key provider you set up in (2).
- For a more detailed overview of the new integration, you can refer to our tutorial at https://stripe.com/docs/mobile/ios/standard
[STPFile stringFromPurpose:]
now returnsnil
forSTPFilePurposeUnknown
. Will return a non-nil value for all otherSTPFilePurpose
.- We've removed the
email
andphone
properties inSTPUserInformation
. You can pre-fill this information in the shipping form using the newshippingAddress
property. - The SMS card fill feature has been removed from
STPPaymentContext
, as well as the associatedsmsAutofillDisabled
configuration option (ie it will now always behave as if it is disabled).
paymentRequestWithMerchantIdentifier:
has been deprecated. You should instead usepaymentRequestWithMerchantIdentifier:country:currency:
. Apple Pay is now available in many countries and currencies, and you should use the appropriate values for your business.- We've added a
paymentCountry
property toSTPPaymentContext
. This affects the countryCode of Apple Pay payments, and defaults to "US". You should set this to the country your Stripe account is in. - Polling for source object updates is deprecated. Check https://stripe.com/docs for the latest best practices on how to integrate with the sources API using webhooks.
paymentMethodsViewController:didSelectPaymentMethod:
is now optional. If you have an empty implementation of this method, you can remove it.
- STPPaymentMethodsViewControllerDelegate now has a separate
paymentMethodsViewControllerDidCancel:
callback, differentiating from successful method selections. You should make sure to also dismiss the view controller in that callback.
- Methods deprecated in Version 6.0 have now been removed.
- The
STPSource
protocol has been renamedSTPSourceProtocol
. STPSource
is now a model object representing a source from the Stripe API. https://stripe.com/docs/sourcesSTPCustomer
will now includeSTPSource
objects in itssources
array if a customer has attached sources.STPErrorCode
andSTPCardErrorCode
are now first class Swift enums (before, their types wereInt
andString
, respectively)
Version 9.0 drops support for iOS 7.x and Xcode 7.x. If you need to support iOS or Xcode versions below 8.0, the last compatible Stripe SDK release is version 8.0.7.
6.0 moves most of the contents of STPCard
into a new class, STPCardParams
, which represents a request to the Stripe API. STPCard
now only refers to responses from the Stripe API. Most apps should be able to simply replace all usage of STPCard
with STPCardParams
- you should only use STPCard
if you're dealing with an API response, e.g. a card attached to an STPToken
. This renaming has been done in a way that will avoid breaking changes, although using STPCard
s to make requests to the Stripe API will produce deprecation warnings.
5.0 deprecates our native Stripe Checkout adapters. If you were using these, we recommend building your own credit card form instead. If you need help with this, please contact [email protected].
Before version 3.0, most token-creation methods were class methods on the Stripe
class. These are now all instance methods on the STPAPIClient
class. Where previously you might write
[Stripe createTokenWithCard:card publishableKey:myPublishableKey completion:completion];
you would now instead write
STPAPIClient *client = [[STPAPIClient alloc] initWithPublishableKey:myPublishableKey];
[client createTokenWithCard:card completion:completion];
This version also made several helper classes, including STPAPIConnection
and STPUtils
, private. You should remove any references to them from your code (most apps shouldn't have any).
Versions of Stripe-iOS prior to 1.2 included a class called STPView
, which provided a pre-built credit card form. This functionality has been moved from Stripe-iOS to PaymentKit, a separate project. If you were using STPView
prior to version 1.2, migrating is simple:
-
Add PaymentKit to your project, as explained on its project page.
-
Replace any references to
STPView
with aPTKView
instead. Similarly, any classes that implementSTPViewDelegate
should now instead implement the equivalentPTKViewDelegate
methods. Note that unlikeSTPView
,PTKView
does not take a Stripe API key in its constructor. -
To submit the credit card details from your
PTKView
instance, where you would previously callcreateToken
on yourSTPView
, replace that with the following code (assumingself.paymentView
is yourPTKView
instance):if (![self.paymentView isValid]) { return; } STPCard *card = [[STPCard alloc] init]; card.number = self.paymentView.card.number; card.expMonth = self.paymentView.card.expMonth; card.expYear = self.paymentView.card.expYear; card.cvc = self.paymentView.card.cvc; STPAPIClient *client = [[STPAPIClient alloc] initWithPublishableKey:publishableKey]; [client createTokenWithCard:card completion:^(STPToken *token, NSError *error) { if (error) { // handle the error as you did previously } else { // submit the token to your payment backend as you did previously } }];
See StripeError.h for a list of error codes that may be returned from the Stripe API.
You have a few options for handling validation of credit card data on the client, depending on what your application does. Client-side validation of credit card data is not required since our API will correctly reject invalid card information, but can be useful to validate information as soon as a user enters it, or simply to save a network request.
The simplest thing you can do is to populate an STPCard
object and, before sending the request, call - (BOOL)validateCardReturningError:
on the card. This validates the entire card object, but is not useful for validating card properties one at a time.
To validate STPCard
properties individually, you should use the following:
- (BOOL)validateNumber:error:
- (BOOL)validateCvc:error:
- (BOOL)validateExpMonth:error:
- (BOOL)validateExpYear:error:
These methods follow the validation method convention used by key-value validation. So, you can use these methods by invoking them directly, or by calling [card validateValue:forKey:error]
for a property on the STPCard
object.
When using these validation methods, you will want to set the property on your card object when a property does validate before validating the next property. This allows the methods to use existing properties on the card correctly to validate a new property. For example, validating 5
for the expMonth
property will return YES if no expYear
is set. But if expYear
is set and you try to set expMonth
to 5 and the combination of expMonth
and expYear
is in the past, 5
will not validate. The order in which you call the validate methods does not matter for this though.