Protocols
The following protocols are available globally.
-
Objects conforming to STPAPIResponseDecodable can be automatically converted from a JSON dictionary that was returned from the Stripe API.
See moreDeclaration
Objective-C
@protocol STPAPIResponseDecodable <NSObject>
Swift
protocol STPAPIResponseDecodable : NSObjectProtocol
-
An
See moreSTPAddCardViewControllerDelegate
is notified when anSTPAddCardViewController
successfully creates a card token or is cancelled. It has internal error-handling logic, so there’s no error case to deal with.Declaration
Objective-C
@protocol STPAddCardViewControllerDelegate <NSObject>
Swift
protocol STPAddCardViewControllerDelegate : NSObjectProtocol
-
Typically, you will not need to implement this protocol yourself. You should instead use
STPCustomerContext
, which implementsand manages retrieving and updating a Stripe customer for you. See
STPCustomerContext.hIf you would prefer retrieving and updating your Stripe customer object via your own backend instead of using
See moreSTPCustomerContext
, you should make your application’s API client conform to this interface. It provides a “bridge” from the prebuilt UI we expose (such asSTPPaymentMethodsViewController
) to your backend to fetch the information it needs to power those views.Declaration
Objective-C
@protocol STPBackendAPIAdapter <NSObject>
Swift
protocol STPBackendAPIAdapter : NSObjectProtocol
-
You should make your application’s API client conform to this interface. It provides a way for
See moreSTPCustomerContext
to request a new ephemeral key from your backend, which it will use to retrieve and update a Stripe customer.Declaration
Objective-C
@protocol STPEphemeralKeyProvider <NSObject>
Swift
protocol STPEphemeralKeyProvider : NSObjectProtocol
-
Objects conforming to STPFormEncodable can be automatically converted to a form-encoded string, which can then be used when making requests to the Stripe API.
See moreDeclaration
Objective-C
@protocol STPFormEncodable <NSObject>
Swift
protocol STPFormEncodable : NSObjectProtocol
-
This protocol allows a delegate to be notified when a payment text field’s contents change, which can in turn be used to take further actions depending on the validity of its contents.
See moreDeclaration
Objective-C
@protocol STPPaymentCardTextFieldDelegate <NSObject>
Swift
protocol STPPaymentCardTextFieldDelegate : NSObjectProtocol
-
Implement
See moreSTPPaymentContextDelegate
to get notified when a payment context changes, finishes, encounters errors, etc. In practice, if your app has a “checkout screen view controller”, that is a good candidate to implement this protocol.Declaration
Objective-C
@protocol STPPaymentContextDelegate <NSObject>
Swift
protocol STPPaymentContextDelegate : NSObjectProtocol
-
This protocol represents a payment method that a user can select and use to pay. Currently the only classes that conform to it are
See moreSTPCard
, which represents that the user wants to pay with a specific card,STPApplePayPaymentMethod
, which represents that the user wants to pay with Apple Pay, andSTPSource
. OnlySTPSource.type == STPSourceTypeCard
payment methods are supported bySTPPaymentContext
andSTPPaymentMethodViewController
, but the other types do have basic support for this protocol for use in a custom integration.Declaration
Objective-C
@protocol STPPaymentMethod <NSObject>
Swift
protocol STPPaymentMethod : NSObjectProtocol
-
An
See moreSTPPaymentMethodsViewControllerDelegate
responds when a user selects a payment method from (or cancels) anSTPPaymentMethodsViewController
. In both of these instances, you should dismiss the view controller (either by popping it off the navigation stack, or dismissing it).Declaration
Objective-C
@protocol STPPaymentMethodsViewControllerDelegate <NSObject>
Swift
protocol STPPaymentMethodsViewControllerDelegate : NSObjectProtocol
-
An
See moreSTPShippingAddressViewControllerDelegate
is notified when anSTPShippingAddressViewController
receives an address, completes with an address, or is cancelled.Declaration
Objective-C
@protocol STPShippingAddressViewControllerDelegate <NSObject>
Swift
protocol STPShippingAddressViewControllerDelegate : NSObjectProtocol
-
Objects conforming to this protocol can be attached to a Stripe Customer object as a payment source.
See moreDeclaration
Objective-C
@protocol STPSourceProtocol <NSObject>
Swift
protocol STPSourceProtocol : NSObjectProtocol