Stripe
Objective-C
@interface Stripe : NSObject
Swift
class Stripe : NSObject
A top-level class that imports the rest of the Stripe SDK.
-
Set your Stripe API key with this method. New instances of STPAPIClient will be initialized with this value. You should call this method as early as possible in your application’s lifecycle, preferably in your AppDelegate.
Warning
Make sure not to ship your test API keys to the App Store! This will log a warning if you use your test key in a release build.Declaration
Objective-C
+ (void)setDefaultPublishableKey:(nonnull NSString *)publishableKey;
Swift
class func setDefaultPublishableKey(_ publishableKey: String)
Parameters
publishableKey
Your publishable key, obtained from https://dashboard.stripe.com/apikeys
-
The current default publishable key.
Declaration
Objective-C
+ (nullable NSString *)defaultPublishableKey;
Swift
class func defaultPublishableKey() -> String?
-
A Boolean value that determines whether additional device data is sent to Stripe for fraud prevention.
Returns YES if the Stripe SDK is collecting additional device data for fraud prevention. For more details on the information we collect, visit https://stripe.com/docs/disputes/prevention/advanced-fraud-detection The default value is YES.
Declaration
Objective-C
+ (BOOL)advancedFraudSignalsEnabled;
Swift
class func advancedFraudSignalsEnabled() -> Bool
-
Set whether additional device data is sent to Stripe for fraud prevention.
Declaration
Objective-C
+ (void)setAdvancedFraudSignalsEnabled:(BOOL)enabled;
Swift
class func setAdvancedFraudSignalsEnabled(_ enabled: Bool)
Parameters
enabled
If YES, additional device signals will be sent to Stripe. For more details on the information we collect, visit https://stripe.com/docs/disputes/prevention/advanced-fraud-detection Disabling this setting will reduce Stripe’s ability to protect your business from fraudulent payments.
-
Whether or not this device is capable of using Apple Pay. This checks both whether the device supports Apple Pay, as well as whether or not they have stored Apple Pay cards on their device.
Declaration
Objective-C
+ (BOOL)canSubmitPaymentRequest:(nonnull PKPaymentRequest *)paymentRequest;
Swift
class func canSubmitPaymentRequest(_ paymentRequest: PKPaymentRequest) -> Bool
Parameters
paymentRequest
The return value of this method depends on the
supportedNetworks
property of this payment request, which by default should be@[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa, PKPaymentNetworkDiscover]
.Return Value
whether or not the user is currently able to pay with Apple Pay.
-
Whether or not this can make Apple Pay payments via a card network supported by Stripe.
The Stripe supported Apple Pay card networks are: American Express, Visa, Mastercard, Discover.
Japanese users can enable JCB by setting
JCBPaymentNetworkSupported
to YES, after they have been approved by JCB.Declaration
Objective-C
+ (BOOL)deviceSupportsApplePay;
Swift
class func deviceSupportsApplePay() -> Bool
Return Value
YES if the device is currently able to make Apple Pay payments via one of the supported networks. NO if the user does not have a saved card of a supported type, or other restrictions prevent payment (such as parental controls).
-
Deprecated
A convenience method to build a
PKPaymentRequest
with sane default values. You will still need to configure thepaymentSummaryItems
property to indicate what the user is purchasing, as well as the optionalrequiredShippingAddressFields
,requiredBillingAddressFields
, andshippingMethods
properties to indicate what contact information your application requires. Note that this method sets the payment request’s countryCode to “US” and its currencyCode to “USD”.Declaration
Objective-C
+ (nonnull PKPaymentRequest *)paymentRequestWithMerchantIdentifier: (nonnull NSString *)merchantIdentifier;
Swift
class func paymentRequest(withMerchantIdentifier merchantIdentifier: String) -> PKPaymentRequest
Parameters
merchantIdentifier
Your Apple Merchant ID.
Return Value
a
PKPaymentRequest
with proper default values. Returns nil if running on < iOS8. @deprecated UsepaymentRequestWithMerchantIdentifier:country:currency:
instead. Apple Pay is available in many countries and currencies, and you should use the appropriate values for your business. -
A convenience method to build a
PKPaymentRequest
with sane default values. You will still need to configure thepaymentSummaryItems
property to indicate what the user is purchasing, as well as the optionalrequiredShippingAddressFields
,requiredBillingAddressFields
, andshippingMethods
properties to indicate what contact information your application requires.Declaration
Objective-C
+ (nonnull PKPaymentRequest *) paymentRequestWithMerchantIdentifier:(nonnull NSString *)merchantIdentifier country:(nonnull NSString *)countryCode currency:(nonnull NSString *)currencyCode;
Swift
class func paymentRequest(withMerchantIdentifier merchantIdentifier: String, country countryCode: String, currency currencyCode: String) -> PKPaymentRequest
Parameters
merchantIdentifier
Your Apple Merchant ID.
countryCode
The two-letter code for the country where the payment will be processed. This should be the country of your Stripe account.
currencyCode
The three-letter code for the currency used by this payment request. Apple Pay interprets the amounts provided by the summary items attached to this request as amounts in this currency.
Return Value
a
PKPaymentRequest
with proper default values. Returns nil if running on < iOS8. -
Deprecated
Set additionalApplePayNetworks = @[PKPaymentNetworkJCB] instead
Japanese users can enable JCB for Apple Pay by setting this to
YES
, after they have been approved by JCB.The default value is NO.
Note
JCB is only supported on iOS 10.1+Declaration
Objective-C
@property (class, nonatomic, assign, unsafe_unretained, readwrite, getter=isJCBPaymentNetworkSupported) BOOL JCBPaymentNetworkSupported;
Swift
class var isJCBPaymentNetworkSupported: Bool { get set }
-
The SDK accepts Amex, Mastercard, Visa, and Discover for Apple Pay. Set this property to enable other card networks in addition to these.
For example,
additionalEnabledApplePayNetworks = @[PKPaymentNetworkJCB];
enables JCB (note this requires onboarding from JCB and Stripe).Declaration
Objective-C
@property (class, nonatomic, copy, nonnull) NSArray<PKPaymentNetwork> *additionalEnabledApplePayNetworks;
Swift
class var additionalEnabledApplePayNetworks: [PKPaymentNetwork] { get set }
-
Call this method in your app delegate whenever you receive an URL in your app delegate for a Stripe callback.
For convenience, you can pass all URL’s you receive in your app delegate to this method first, and check the return value to easily determine whether it is a callback URL that Stripe will handle or if your app should process it normally.
If you are using a universal link URL, you will receive the callback in
application:continueUserActivity:restorationHandler:
To learn more about universal links, see https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.htmlIf you are using a native scheme URL, you will receive the callback in
application:openURL:options:
To learn more about native url schemes, see https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html#//apple_ref/doc/uid/TP40007072-CH6-SW10Declaration
Objective-C
+ (BOOL)handleStripeURLCallbackWithURL:(nonnull NSURL *)url;
Swift
class func handleURLCallback(with url: URL) -> Bool
Parameters
url
The URL that you received in your app delegate
Return Value
YES if the URL is expected and will be handled by Stripe. NO otherwise.