STPCustomerContext
@interface STPCustomerContext : NSObject <STPBackendAPIAdapter>
An STPCustomerContext retrieves and updates a Stripe customer using
an ephemeral key, a short-lived API key scoped to a specific customer object.
If your current user logs out of your app and a new user logs in, be sure to
either create a new instance of STPCustomerContext or clear the current
instance’s cached customer. On your backend, be sure to create and return a
new ephemeral key for the Customer object associated with the new user.
-
Initializes a new
STPCustomerContextwith the specified key provider. Upon initialization, a CustomerContext will fetch a new ephemeral key from your backend and use it to prefetch the customer object specified in the key. Subsequent customer retrievals (e.g. bySTPPaymentContext) will return the prefetched customer immediately if its age does not exceedcachedCustomerMaxAge.Declaration
Objective-C
- (nonnull instancetype)initWithKeyProvider: (nonnull id<STPEphemeralKeyProvider>)keyProvider;Parameters
keyProviderThe key provider the customer context will use.
Return Value
the newly-instantiated customer context.
-
STPCustomerContextwill cache its customer object for up to 60 seconds. If your current user logs out of your app and a new user logs in, be sure to either call this method or create a new instance ofSTPCustomerContext. On your backend, be sure to create and return a new ephemeral key for the customer object associated with the new user.Declaration
Objective-C
- (void)clearCachedCustomer;Swift
func clearCachedCustomer()
View on GitHub
STPCustomerContext Class Reference