STPPushProvisioningContext

public class STPPushProvisioningContext : NSObject

This class makes it easier to implement “Push Provisioning”, the process by which an end-user can add a card to their Apple Pay wallet without having to type their number. This process is mediated by an Apple class called PKAddPaymentPassViewController; this class will help you implement that class’ delegate methods. Note that this flow requires a special entitlement from Apple; for more information please see https://stripe.com/docs/issuing/cards/digital-wallets .

  • The API Client to use to make requests. Defaults to STPAPIClient.shared

    Declaration

    Swift

    public var apiClient: STPAPIClient
  • The STPAPIClient instance to use to make API requests to Stripe. Defaults to STPAPIClient.shared.

    Declaration

    Swift

    @available(swift, deprecated: 0.0.1, renamed: "apiClient")
    @objc(apiClient)
    public var _objc_apiClient: _stpobjc_STPAPIClient { get set }
  • This is a helper method to generate a PKAddPaymentPassRequestConfiguration that will work with Stripe’s Issuing APIs. Pass the returned configuration object to PKAddPaymentPassViewController‘s initWithRequestConfiguration:delegate: initializer. @deprecated Use requestConfiguration(withName:description:last4:brand:primaryAccountIdentifier:) instead.

    Declaration

    Swift

    @available(*, deprecated, renamed: "requestConfiguration(withName:description:last4:brand:primaryAccountIdentifier:﹚", message: "Use `requestConfiguration(withName:description:last4:brand:primaryAccountIdentifier:﹚` instead.")
    @objc
    public class func requestConfiguration(
        withName name: String,
        description: String?,
        last4: String?,
        brand: STPCardBrand
    ) -> PKAddPaymentPassRequestConfiguration

    Parameters

    name

    Your cardholder’s name. Example: John Appleseed

    description

    A localized description of your card’s name. This will appear in Apple’s UI as “{description} will be available in Wallet”. Example: Platinum Rewards Card

    last4

    The last 4 of the card to be added to the user’s Apple Pay wallet. Example: 4242

    brand

    The brand of the card. Example: STPCardBrandVisa

  • This is a helper method to generate a PKAddPaymentPassRequestConfiguration that will work with Stripe’s Issuing APIs. Pass the returned configuration object to PKAddPaymentPassViewController‘s initWithRequestConfiguration:delegate: initializer.

    Declaration

    Swift

    @objc
    public class func requestConfiguration(
        withName name: String,
        description: String?,
        last4: String?,
        brand: STPCardBrand,
        primaryAccountIdentifier: String?
    ) -> PKAddPaymentPassRequestConfiguration

    Parameters

    name

    Your cardholder’s name. Example: John Appleseed

    description

    A localized description of your card’s name. This will appear in Apple’s UI as “{description} will be available in Wallet”. Example: Platinum Rewards Card

    last4

    The last 4 of the card to be added to the user’s Apple Pay wallet. Example: 4242

    brand

    The brand of the card. Example: STPCardBrandVisa

    primaryAccountIdentifier

    The primary_account_identifier value from the issued card.

  • In order to retreive the encrypted payload that PKAddPaymentPassViewController expects, the Stripe SDK must talk to the Stripe API. As this requires privileged access, you must write a “key provider” that generates an Ephemeral Key on your backend and provides it to the SDK when requested. For more information, see https://stripe.com/docs/mobile/ios/basic#ephemeral-key

    Declaration

    Swift

    @objc
    public init(keyProvider: STPIssuingCardEphemeralKeyProvider)
  • This method lines up with the method of the same name on PKAddPaymentPassViewControllerDelegate. You should implement that protocol in your own app, and when that method is called, call this method on your STPPushProvisioningContext. This in turn will first initiate a call to your keyProvider (see above) to obtain an Ephemeral Key, then make a call to the Stripe Issuing API to fetch an encrypted payload for the card in question, then return that payload to iOS.

    Declaration

    Swift

    @objc
    public func addPaymentPassViewController(
        _ controller: PKAddPaymentPassViewController,
        generateRequestWithCertificateChain certificates: [Data], nonce: Data, nonceSignature: Data,
        completionHandler handler: @escaping (PKAddPaymentPassRequest) -> Void
    )