STPPaymentOptionsViewController
@interface STPPaymentOptionsViewController : STPCoreViewController
This view controller presents a list of payment method options to the user, which they can select between. They can also add credit cards to the list.
It must be displayed inside a UINavigationController
, so you can either
create a UINavigationController
with an STPPaymentOptionsViewController
as the rootViewController
and then present the UINavigationController
,
or push a new STPPaymentOptionsViewController
onto an existing
UINavigationController
‘s stack. You can also have STPPaymentContext
do this
for you automatically, by calling presentPaymentOptionsViewController
or pushPaymentOptionsViewController
on it.
-
The delegate for the view controller.
The delegate receives callbacks when the user selects a method or cancels, and is responsible for dismissing the payments methods view controller when it is finished.
Declaration
Objective-C
@property (nonatomic, weak, readonly, nullable) id<STPPaymentOptionsViewControllerDelegate> delegate;
Swift
weak var delegate: STPPaymentOptionsViewControllerDelegate? { get }
-
Creates a new payment methods view controller.
Declaration
Objective-C
- (nonnull instancetype)initWithPaymentContext: (nonnull STPPaymentContext *)paymentContext;
Swift
init(paymentContext: STPPaymentContext)
Parameters
paymentContext
A payment context to power the view controller’s view. The payment context will in turn use its backend API adapter to fetch the information it needs from your application.
Return Value
an initialized view controller.
-
Initializes a new payment methods view controller without using a payment context.
Declaration
Objective-C
- (nonnull instancetype) initWithConfiguration:(nonnull STPPaymentConfiguration *)configuration theme:(nonnull STPTheme *)theme customerContext:(nonnull STPCustomerContext *)customerContext delegate:(nonnull id<STPPaymentOptionsViewControllerDelegate>) delegate;
Swift
init(configuration: STPPaymentConfiguration, theme: STPTheme, customerContext: STPCustomerContext, delegate: STPPaymentOptionsViewControllerDelegate)
Parameters
configuration
The configuration to use to determine what types of payment method to offer your user. - see: STPPaymentConfiguration.h
theme
The theme to inform the appearance of the UI.
customerContext
The customer context the view controller will use to fetch and modify its Stripe customer
delegate
A delegate that will be notified when the payment methods view controller’s selection changes.
Return Value
an initialized view controller.
-
Note: Instead of providing your own backend API adapter, we recommend using
STPCustomerContext
, which will manage retrieving and updating a Stripe customer for you. - see: STPCustomerContext.hInitializes a new payment methods view controller without using a payment context.
Declaration
Objective-C
- (nonnull instancetype) initWithConfiguration:(nonnull STPPaymentConfiguration *)configuration theme:(nonnull STPTheme *)theme apiAdapter:(nonnull id<STPBackendAPIAdapter>)apiAdapter delegate:(nonnull id<STPPaymentOptionsViewControllerDelegate>) delegate;
Swift
init(configuration: STPPaymentConfiguration, theme: STPTheme, apiAdapter: STPBackendAPIAdapter, delegate: STPPaymentOptionsViewControllerDelegate)
Parameters
configuration
The configuration to use to determine what types of payment method to offer your user.
theme
The theme to inform the appearance of the UI.
apiAdapter
The API adapter to use to retrieve a customer’s stored payment methods and save new ones.
delegate
A delegate that will be notified when the payment methods view controller’s selection changes.
-
If you’ve already collected some information from your user, you can set it here and it’ll be automatically filled out when possible/appropriate in any UI that the payment context creates.
Declaration
Objective-C
@property (nonatomic, strong, readwrite, nullable) STPUserInformation *prefilledInformation;
Swift
var prefilledInformation: STPUserInformation? { get set }
-
A view that will be placed as the footer of the view controller when it is showing a list of saved payment methods to select from.
When the footer view needs to be resized, it will be sent a
sizeThatFits:
call. The view should respond correctly to this method in order to be sized and positioned properly.Declaration
Objective-C
@property (nonatomic, strong, readwrite) UIView *_Nonnull paymentOptionsViewControllerFooterView;
Swift
var paymentOptionsViewControllerFooterView: UIView { get set }
-
A view that will be placed as the footer of the view controller when it is showing the add card view.
When the footer view needs to be resized, it will be sent a
sizeThatFits:
call. The view should respond correctly to this method in order to be sized and positioned properly.Declaration
Objective-C
@property (nonatomic, strong, readwrite) UIView *_Nonnull addCardViewControllerFooterView;
Swift
var addCardViewControllerFooterView: UIView { get set }
-
If you’re pushing
STPPaymentOptionsViewController
onto an existingUINavigationController
‘s stack, you should use this method to dismiss it, since it may have pushed an additional add card view controller onto the navigation controller’s stack.Declaration
Objective-C
- (void)dismissWithCompletion:(nullable STPVoidBlock)completion;
Swift
func dismiss(completion: STPVoidBlock? = nil)
Parameters
completion
The callback to run after the view controller is dismissed. You may specify nil for this parameter.
-
Unavailable
Use one of the initializers declared in this interface.
Declaration
Objective-C
- (nonnull instancetype)initWithTheme:(nonnull STPTheme *)theme;
-
Unavailable
Use one of the initializers declared in this interface.
Declaration
Objective-C
- (nonnull instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil;
-
Unavailable
Use one of the initializers declared in this interface.
Declaration
Objective-C
- (nullable instancetype)initWithCoder:(nonnull NSCoder *)aDecoder;