STPPushProvisioningContext
Objective-C
@interface STPPushProvisioningContext : NSObject
Swift
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 sharedClient]
Declaration
Objective-C
@property (nonatomic, strong) STPAPIClient *_Nonnull apiClient;
Swift
var apiClient: 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
‘sinitWithRequestConfiguration:delegate:
initializer.Declaration
Objective-C
+ (nonnull PKAddPaymentPassRequestConfiguration *) requestConfigurationWithName:(nonnull NSString *)name description:(nullable NSString *)description last4:(nullable NSString *)last4 brand:(STPCardBrand)brand;
Swift
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
-
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
Objective-C
- (nonnull instancetype)initWithKeyProvider: (nonnull id<STPIssuingCardEphemeralKeyProvider>)keyProvider;
Swift
init(keyProvider: STPIssuingCardEphemeralKeyProvider)
-
-addPaymentPassViewController:
generateRequestWithCertificateChain: nonce: nonceSignature: completionHandler: 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 yourSTPPushProvisioningContext
. This in turn will first initiate a call to yourkeyProvider
(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
Objective-C
- (void)addPaymentPassViewController: (nonnull PKAddPaymentPassViewController *)controller generateRequestWithCertificateChain: (nonnull NSArray<NSData *> *)certificates nonce:(nonnull NSData *)nonce nonceSignature:(nonnull NSData *)nonceSignature completionHandler: (nonnull void (^)(PKAddPaymentPassRequest *_Nonnull)) handler;
Swift
func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, generateRequestWithCertificateChain certificates: [Data], nonce: Data, nonceSignature: Data, completionHandler handler: @escaping (PKAddPaymentPassRequest) -> Void)