STPAddCardViewControllerDelegate
@protocol STPAddCardViewControllerDelegate <NSObject>
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
Objective-C
- (void)addCardViewControllerDidCancel: (nonnull STPAddCardViewController *)addCardViewController;
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
Objective-C
- (void)addCardViewController: (nonnull STPAddCardViewController *)addCardViewController didCreatePaymentMethod:(nonnull STPPaymentMethod *)paymentMethod completion:(nonnull STPErrorBlock)completion;
Swift
optional 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. - see: STPPaymentMethod
completion
call this callback when you’re done sending the token to your backend