Stripe

@interface 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://stripe.com/account/apikeys

  • The current default publishable key.

    Declaration

    Objective-C

    + (nullable NSString *)defaultPublishableKey;

    Swift

    class func defaultPublishableKey() -> String?
  • 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 the paymentSummaryItems property to indicate what the user is purchasing, as well as the optional requiredShippingAddressFields, requiredBillingAddressFields, and shippingMethods 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 Use paymentRequestWithMerchantIdentifier: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 the paymentSummaryItems property to indicate what the user is purchasing, as well as the optional requiredShippingAddressFields, requiredBillingAddressFields, and shippingMethods 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 (getter=isJCBPaymentNetworkSupported, assign, readwrite, nonatomic,
              class) 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 (readwrite, copy, nonatomic, nonnull, class)
        NSArray<PKPaymentNetwork> *additionalEnabledApplePayNetworks;

    Swift

    class var additionalEnabledApplePayNetworks: [PKPaymentNetwork] { get set }