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 card token.
Note: If
createsCardSource
is true, this method will not be called;addCardViewController:didCreateSource:
will be called instead.You should send the token 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 didCreateToken:(nonnull STPToken *)token completion:(nonnull STPErrorBlock)completion;
Swift
optional func addCardViewController(_ addCardViewController: STPAddCardViewController, didCreateToken token: STPToken, completion: @escaping STPErrorBlock)
Parameters
addCardViewController
the view controller that successfully created a token
token
the Stripe token that was created. - see: STPToken
completion
call this callback when you’re done sending the token to your backend
-
This is called when the user successfully adds a card and Stripe returns a card source.
Note: If
createsCardSource
is false, this method will not be called;addCardViewController:didCreateToken:
will be called instead.You should send the source 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 didCreateSource:(nonnull STPSource *)source completion:(nonnull STPErrorBlock)completion;
Swift
optional func addCardViewController(_ addCardViewController: STPAddCardViewController, didCreateSource source: STPSource, completion: @escaping STPErrorBlock)
Parameters
addCardViewController
the view controller that successfully created a token
source
the Stripe source that was created. - see: STPSource
completion
call this callback when you’re done sending the token to your backend