STPPaymentMethodsViewController

@interface STPPaymentMethodsViewController : 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 STPPaymentMethodsViewController as the rootViewController and then present the UINavigationController, or push a new STPPaymentMethodsViewController onto an existing UINavigationController‘s stack. You can also have STPPaymentContext do this for you automatically, by calling presentPaymentMethodsViewController or pushPaymentMethodsViewController 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 (readonly, nonatomic, nullable)
        id<STPPaymentMethodsViewControllerDelegate>
            delegate;

    Swift

    weak var delegate: STPPaymentMethodsViewControllerDelegate? { 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<STPPaymentMethodsViewControllerDelegate>)delegate;

    Swift

    init(configuration: STPPaymentConfiguration, theme: STPTheme, customerContext: STPCustomerContext, delegate: STPPaymentMethodsViewControllerDelegate)

    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.h

    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
               apiAdapter:(nonnull id<STPBackendAPIAdapter>)apiAdapter
                 delegate:
                     (nonnull id<STPPaymentMethodsViewControllerDelegate>)delegate;

    Swift

    init(configuration: STPPaymentConfiguration, theme: STPTheme, apiAdapter: STPBackendAPIAdapter, delegate: STPPaymentMethodsViewControllerDelegate)

    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 (readwrite, strong, nonatomic, 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 (readwrite, strong, nonatomic)
        UIView *_Nonnull paymentMethodsViewControllerFooterView;

    Swift

    var paymentMethodsViewControllerFooterView: 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 (readwrite, strong, nonatomic)
        UIView *_Nonnull addCardViewControllerFooterView;

    Swift

    var addCardViewControllerFooterView: UIView { get set }
  • If you’re pushing STPPaymentMethodsViewController onto an existing UINavigationController‘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.

  • Use one of the initializers declared in this interface.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithTheme:(nonnull STPTheme *)theme;
  • Use one of the initializers declared in this interface.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithNibName:(nullable NSString *)nibNameOrNil
                                     bundle:(nullable NSBundle *)nibBundleOrNil;
  • Use one of the initializers declared in this interface.

    Declaration

    Objective-C

    - (nullable instancetype)initWithCoder:(nonnull NSCoder *)aDecoder;