STPPaymentCardTextFieldDelegate
@objc
public protocol STPPaymentCardTextFieldDelegate : NSObjectProtocol
This protocol allows a delegate to be notified when a payment text field’s contents change, which can in turn be used to take further actions depending on the validity of its contents.
-
Called when either the card number, expiration, or CVC changes. At this point, one can call
isValid
on the text field to determine, for example, whether or not to enable a button to submit the form. Example:- (void)paymentCardTextFieldDidChange:(STPPaymentCardTextField *)textField { self.paymentButton.enabled = textField.isValid; }
Declaration
Swift
@objc optional func paymentCardTextFieldDidChange(_ textField: STPPaymentCardTextField)
Parameters
textField
the text field that has changed
-
Called when editing begins in the text field as a whole. After receiving this callback, you will always also receive a callback for which specific subfield of the view began editing.
Declaration
Swift
@objc optional func paymentCardTextFieldDidBeginEditing(_ textField: STPPaymentCardTextField)
-
Notification that the user pressed the
return
key after completely filling out the STPPaymentCardTextField with data that passes validation. The Stripe SDK is going toresignFirstResponder
on theSTPPaymentCardTextField
to dismiss the keyboard after this delegate method returns, however if your app wants to do something more (ex: move first responder to another field), this is a good opportunity to do that. This is delivered before the correspondingpaymentCardTextFieldDidEndEditing:
Declaration
Swift
@objc optional func paymentCardTextFieldWillEndEditing( forReturn textField: STPPaymentCardTextField)
Parameters
textField
The STPPaymentCardTextField that was being edited when the user pressed return
-
Called when editing ends in the text field as a whole. This callback is always preceded by an callback for which specific subfield of the view ended its editing.
Declaration
Swift
@objc optional func paymentCardTextFieldDidEndEditing(_ textField: STPPaymentCardTextField)
-
Called when editing begins in the payment card field’s number field.
Declaration
Swift
@objc optional func paymentCardTextFieldDidBeginEditingNumber( _ textField: STPPaymentCardTextField)
-
Called when editing ends in the payment card field’s number field.
Declaration
Swift
@objc optional func paymentCardTextFieldDidEndEditingNumber(_ textField: STPPaymentCardTextField)
-
Called when editing begins in the payment card field’s CVC field.
Declaration
Swift
@objc optional func paymentCardTextFieldDidBeginEditingCVC(_ textField: STPPaymentCardTextField)
-
Called when editing ends in the payment card field’s CVC field.
Declaration
Swift
@objc optional func paymentCardTextFieldDidEndEditingCVC(_ textField: STPPaymentCardTextField)
-
Called when editing begins in the payment card field’s expiration field.
Declaration
Swift
@objc optional func paymentCardTextFieldDidBeginEditingExpiration( _ textField: STPPaymentCardTextField)
-
Called when editing ends in the payment card field’s expiration field.
Declaration
Swift
@objc optional func paymentCardTextFieldDidEndEditingExpiration( _ textField: STPPaymentCardTextField)
-
Called when editing begins in the payment card field’s ZIP/postal code field.
Declaration
Swift
@objc optional func paymentCardTextFieldDidBeginEditingPostalCode( _ textField: STPPaymentCardTextField)
-
Called when editing ends in the payment card field’s ZIP/postal code field.
Declaration
Swift
@objc optional func paymentCardTextFieldDidEndEditingPostalCode( _ textField: STPPaymentCardTextField)