STPPaymentHandler


@interface STPPaymentHandler : NSObject

STPPaymentHandler is a utility class that confirms PaymentIntents/SetupIntents and handles any authentication required, such as 3DS1/3DS2 for Strong Customer Authentication. It can present authentication UI on top of your app or redirect users out of your app (to e.g. their banking app).

  • The globally shared instance of STPPaymentHandler.

    Declaration

    Objective-C

    + (nonnull instancetype)sharedHandler;

    Swift

    class func shared() -> Self
  • Unavailable

    STPPaymentHandler should not be directly initialized.

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • By default sharedHandler initializes with [STPAPIClient sharedClient].

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) STPAPIClient *_Nonnull apiClient;

    Swift

    var apiClient: STPAPIClient { get set }
  • Customizable settings to use when performing 3DS2 authentication.

    Note: Configure this before calling any methods. Defaults to [STPThreeDSCustomizationSettings defaultSettings].

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        STPThreeDSCustomizationSettings *_Nonnull threeDSCustomizationSettings;

    Swift

    var threeDSCustomizationSettings: STPThreeDSCustomizationSettings { get set }
  • Confirms the PaymentIntent with the provided parameters and handles any nextAction required to authenticate the PaymentIntent.

    Call this method if you are using automatic confirmation. - see: https://stripe.com/docs/payments/payment-intents/ios

    Declaration

    Objective-C

    - (void)confirmPayment:(nonnull STPPaymentIntentParams *)paymentParams
        withAuthenticationContext:
            (nonnull id<STPAuthenticationContext>)authenticationContext
                       completion:
                           (nonnull
                                STPPaymentHandlerActionPaymentIntentCompletionBlock)
                               completion;

    Parameters

    paymentParams

    The params used to confirm the PaymentIntent. Note that this method overrides the value of paymentParams.useStripeSDK to @YES.

    authenticationContext

    The authentication context used to authenticate the payment.

    completion

    The completion block. If the status returned is STPPaymentHandlerActionStatusSucceeded, the PaymentIntent status will always be either STPPaymentIntentStatusSucceeded or STPPaymentIntentStatusRequiresCapture if you are using manual capture. In the latter case, capture the PaymentIntent to complete the payment.

  • Handles any nextAction required to authenticate the PaymentIntent.

    Call this method if you are using manual confirmation. - see: https://stripe.com/docs/payments/payment-intents/ios

    Declaration

    Objective-C

    - (void)
        handleNextActionForPayment:(nonnull NSString *)paymentIntentClientSecret
         withAuthenticationContext:
             (nonnull id<STPAuthenticationContext>)authenticationContext
                         returnURL:(nullable NSString *)returnURL
                        completion:
                            (nonnull
                                 STPPaymentHandlerActionPaymentIntentCompletionBlock)
                                completion;

    Parameters

    paymentIntentClientSecret

    The client secret of the PaymentIntent to handle next actions for.

    authenticationContext

    The authentication context used to authenticate the payment.

    returnURL

    An optional URL to redirect your customer back to after they authenticate or cancel in a webview. This should match the returnURL you specified during PaymentIntent confirmation.

    completion

    The completion block. If the status returned is STPPaymentHandlerActionStatusSucceeded, the PaymentIntent status will always be either STPPaymentIntentStatusSucceeded, or STPPaymentIntentStatusRequiresConfirmation, or STPPaymentIntentStatusRequiresCapture if you are using manual capture. In the latter two cases, confirm or capture the PaymentIntent on your backend to complete the payment.

  • Confirms the SetupIntent with the provided parameters and handles any nextAction required to authenticate the SetupIntent.

    Declaration

    Objective-C

    - (void)confirmSetupIntent:
                (nonnull STPSetupIntentConfirmParams *)setupIntentConfirmParams
        withAuthenticationContext:
            (nonnull id<STPAuthenticationContext>)authenticationContext
                       completion:
                           (nonnull
                                STPPaymentHandlerActionSetupIntentCompletionBlock)
                               completion;

    Parameters

    setupIntentConfirmParams

    The params used to confirm the SetupIntent. Note that this method overrides the value of setupIntentConfirmParams.useStripeSDK to @YES.

    authenticationContext

    The authentication context used to authenticate the SetupIntent.

    completion

    The completion block. If the status returned is STPPaymentHandlerActionStatusSucceeded, the SetupIntent status will always be STPSetupIntentStatusSucceeded.

  • Handles any nextAction required to authenticate the SetupIntent.

    Call this method if you are confirming the SetupIntent on your backend and get a status of requires_action.

    Declaration

    Objective-C

    - (void)
        handleNextActionForSetupIntent:(nonnull NSString *)setupIntentClientSecret
             withAuthenticationContext:
                 (nonnull id<STPAuthenticationContext>)authenticationContext
                             returnURL:(nullable NSString *)returnURL
                            completion:
                                (nonnull
                                     STPPaymentHandlerActionSetupIntentCompletionBlock)
                                    completion;

    Parameters

    setupIntentClientSecret

    The client secret of the SetupIntent to handle next actions for.

    authenticationContext

    The authentication context used to authenticate the SetupIntent.

    returnURL

    An optional URL to redirect your customer back to after they authenticate or cancel in a webview. This should match the returnURL you specified during SetupIntent confirmation.

    completion

    The completion block. If the status returned is STPPaymentHandlerActionStatusSucceeded, the SetupIntent status will always be STPSetupIntentStatusSucceeded.