STPPaymentHandler
@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)
public class STPPaymentHandler : NSObject, SFSafariViewControllerDelegate, STPURLCallbackListener
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 error domain for errors in
STPPaymentHandler
.Declaration
Swift
@objc public static let errorDomain: String
-
The globally shared instance of
STPPaymentHandler
.Declaration
Swift
@objc public static let sharedHandler: STPPaymentHandler
-
The globally shared instance of
STPPaymentHandler
.Declaration
Swift
@objc public class func shared() -> STPPaymentHandler
-
By default
sharedHandler
initializes with STPAPIClient.shared.Declaration
Swift
@objc public var apiClient: STPAPIClient
-
Customizable settings to use when performing 3DS2 authentication. Note: Configure this before calling any methods. Defaults to
STPThreeDSCustomizationSettings.defaultSettings()
.Declaration
Swift
@objc public var threeDSCustomizationSettings: STPThreeDSCustomizationSettings
-
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. - seealso: https://stripe.com/docs/payments/payment-intents/iosDeclaration
Swift
@objc(confirmPayment:withAuthenticationContext:completion:) public func confirmPayment( _ paymentParams: STPPaymentIntentParams, with authenticationContext: STPAuthenticationContext, completion: @escaping STPPaymentHandlerActionPaymentIntentCompletionBlock )
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. - seealso: https://stripe.com/docs/payments/payment-intents/iosDeclaration
Swift
@objc(handleNextActionForPayment:withAuthenticationContext:returnURL:completion:) public func handleNextAction( forPayment paymentIntentClientSecret: String, with authenticationContext: STPAuthenticationContext, returnURL: String?, completion: @escaping STPPaymentHandlerActionPaymentIntentCompletionBlock )
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
Swift
@objc(confirmSetupIntent:withAuthenticationContext:completion:) public func confirmSetupIntent( _ setupIntentConfirmParams: STPSetupIntentConfirmParams, with authenticationContext: STPAuthenticationContext, completion: @escaping STPPaymentHandlerActionSetupIntentCompletionBlock )
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
Swift
@objc(handleNextActionForSetupIntent:withAuthenticationContext:returnURL:completion:) public func handleNextAction( forSetupIntent setupIntentClientSecret: String, with authenticationContext: STPAuthenticationContext, returnURL: String?, completion: @escaping STPPaymentHandlerActionSetupIntentCompletionBlock )
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.