STPAddCardViewControllerDelegate
@objc
public protocol STPAddCardViewControllerDelegate : NSObjectProtocol
An STPAddCardViewControllerDelegate
is notified when an STPAddCardViewController
successfully creates a card token or is cancelled. It has internal error-handling
logic, so there’s no error case to deal with.
-
Called when the user cancels adding a card. You should dismiss (or pop) the view controller at this point.
Declaration
Swift
func addCardViewControllerDidCancel(_ addCardViewController: STPAddCardViewController)
Parameters
addCardViewController
the view controller that has been cancelled
-
This is called when the user successfully adds a card and Stripe returns a Payment Method. You should send the PaymentMethod to your backend to store it on a customer, and then call the provided
completion
block when that call is finished. If an error occurs while talking to your backend, callcompletion(error)
, otherwise, dismiss (or pop) the view controller.Declaration
Swift
@objc func addCardViewController( _ addCardViewController: STPAddCardViewController, didCreatePaymentMethod paymentMethod: STPPaymentMethod, completion: @escaping STPErrorBlock )
Parameters
addCardViewController
the view controller that successfully created a token
paymentMethod
the Payment Method that was created. - seealso: STPPaymentMethod
completion
call this callback when you’re done sending the token to your backend
-
This method is deprecated as of v16.0.0 (https://github.com/stripe/stripe-ios/blob/master/MIGRATING.md#migrating-from-versions–1600). To use this class, migrate your integration from Charges to PaymentIntents. See https://stripe.com/docs/payments/payment-intents/migration/charges#read
Declaration
Swift
@available(*, deprecated, renamed: "addCardViewController(_:didCreatePaymentMethod:completion:﹚", message: "Use addCardViewController(_:didCreatePaymentMethod:completion:﹚ instead and migrate your integration to PaymentIntents. See https://stripe.com/docs/payments/payment-intents/migration/charges#read") @objc optional func addCardViewController( _ addCardViewController: STPAddCardViewController, didCreateToken token: STPToken, completion: STPErrorBlock )
-
This method is deprecated as of v16.0.0 (https://github.com/stripe/stripe-ios/blob/master/MIGRATING.md#migrating-from-versions–1600). To use this class, migrate your integration from Charges to PaymentIntents. See https://stripe.com/docs/payments/payment-intents/migration/charges#read
Declaration
Swift
@available(*, deprecated, renamed: "addCardViewController(_:didCreatePaymentMethod:completion:﹚", message: "Use addCardViewController(_:didCreatePaymentMethod:completion:﹚ instead and migrate your integration to PaymentIntents. See https://stripe.com/docs/payments/payment-intents/migration/charges#read") @objc optional func addCardViewController( _ addCardViewController: STPAddCardViewController, didCreateSource source: STPSource, completion: STPErrorBlock )