StripeAPI

public class StripeAPI : NSObject

A top-level class that imports the rest of the Stripe SDK.

  • Set this to your Stripe publishable API key, obtained from https://dashboard.stripe.com/apikeys. Set this as early as possible in your application’s lifecycle, preferably in your AppDelegate or SceneDelegate. New instances of STPAPIClient will be initialized with this value. @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

    Swift

    @objc
    public static var defaultPublishableKey: String?
  • Set this to your Stripe publishable API key, obtained from https://dashboard.stripe.com/apikeys. Set this as early as possible in your application’s lifecycle, preferably in your AppDelegate or SceneDelegate. New instances of STPAPIClient will be initialized with this value. @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

    Swift

    public func setDefaultPublishableKey(_ publishableKey: String)
  • A Boolean value that determines whether additional device data is sent to Stripe for fraud prevention. 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. The default value is YES.

    Declaration

    Swift

    @objc
    public static var advancedFraudSignalsEnabled: Bool

Apple Pay

  • 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

    Swift

    @objc
    public class var jcbPaymentNetworkSupported: 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 = [.JCB] enables JCB (note this requires onboarding from JCB and Stripe).

    Declaration

    Swift

    @objc
    public static var additionalEnabledApplePayNetworks: [PKPaymentNetwork]
  • 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

    Swift

    @objc
    public 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 [.amex, .masterCard, .visa, .discover].

    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

    Swift

    @objc
    dynamic public 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).

  • 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

    Swift

    @available(*, deprecated, message: "Use `paymentRequestWithMerchantIdentifier:country:currency:` instead.")
    @objc
    public 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

    Swift

    @objc
    public 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.

URL callbacks