OPPaymentCardCvvView

@objc
public class OPPaymentCardCvvView : UIView, UIKeyInput, OPPaymentCardCvvTextFieldDelegate, OPValidStateChangedDelegate

Convenience view for gathering CVV details from a user

Important

CVV details are intentionally restricted for PCI compliance
  • An optional handler for providing custom error messages that are displayed when displayGeneratedErrorMessages is true. Regardless of whether error messages are displayed or not, error messages can be retrieved by calling OPPaymentCardCvvView.getErrorMessage(...)

    Declaration

    Swift

    @objc
    public static var errorMessageHandler: OPCvvErrorMessageBlock? { get set }
  • Delegate for callbacks related to text editing in this view

    Declaration

    Swift

    @objc
    public var cvvDetailsDelegate: OPPaymentCardCvvViewDelegate?
  • Provides a snapshot of the current state of this view

    Declaration

    Swift

    @objc
    public var fieldState: OPCardFieldStateProtocol { get }
  • Whether or not error messages should be displayed based on user input. Defaults to true

    Declaration

    Swift

    @objc
    public var displayGeneratedErrorMessages: Bool { get set }
  • Use this to clear or set the currently displayed error message. If displayGeneratedErrorMessages is true then this will be set and cleared automatically based on user input. If false this can be used to set and clear your own error messages

    Declaration

    Swift

    @objc
    public var errorMessage: String { get set }
  • The keyboard appearance for the field. Default is UIKeyboardAppearance.default

    Declaration

    Swift

    public var keyboardAppearance: UIKeyboardAppearance { get set }
  • The font used in the CVV field. Default is UIFont.systemFont(ofSize: 18)

    Declaration

    Swift

    @objc
    public var cvvFont: UIFont { get set }
  • The text color used when entering valid text. Default is .label

    Declaration

    Swift

    @objc
    public var cvvTextColor: UIColor { get set }
  • The font used for error text. Default is UIFont.systemFont(ofSize: 14)

    Declaration

    Swift

    @objc
    public var errorFont: UIFont { get set }
  • The alignment of the built in error message, default is .center

    Declaration

    Swift

    @objc
    public var errorTextAlignment: NSTextAlignment { get set }
  • The text color used when the user has entered invalid information, such as an incomplete CVV. Default is .systemRed

    Declaration

    Swift

    @objc
    public var errorTextColor: UIColor { get set }
  • The text color used for placeholder text. Default is .systemGray2

    Declaration

    Swift

    @objc
    public var placeholderColor: UIColor { get set }
  • The text used as a placeholder when the user has not entered any text. Default is CVV

    Declaration

    Swift

    @objc
    public var placeholderText: String { get set }
  • The cursor color for the field. This is a proxy for the view’s tintColor property, exposed for clarity only (in other words, setting cursorColor is identical to setting tintColor)

    Declaration

    Swift

    @objc
    public var cursorColor: UIColor { get set }
  • The border color for the field. Can be nil (in which case no border will be drawn). Default is .systemGray2

    Declaration

    Swift

    @objc
    public var borderColor: UIColor? { get set }
  • The width of the field’s border. Default is 1.0

    Declaration

    Swift

    @objc
    public var borderWidth: CGFloat { get set }
  • The corner radius for the field’s border. Default is 5.0

    Declaration

    Swift

    @objc
    public var cornerRadius: CGFloat { get set }
  • The padding between the border of the CVV input field and the text. Default is 10 on all sides

    Declaration

    Swift

    @objc
    public var contentPadding: UIEdgeInsets { get set }
  • The alignment of the text within the view

    Declaration

    Swift

    @objc
    public var textAlignment: NSTextAlignment { get set }
  • Whether or not the input field is empty

    Declaration

    Swift

    public var hasText: Bool { get }
  • Whether or not the input field contains a valid CVV format

    Declaration

    Swift

    @objc
    public var isValid: Bool { get }
  • The background color for the CVV input field

    Declaration

    Swift

    public override var backgroundColor: UIColor? { get set }
  • The custom accessory view to display when this view becomes the first responder

    Declaration

    Swift

    public override var inputAccessoryView: UIView? { get set }
  • Enable/disable selecting or editing the field

    Declaration

    Swift

    @objc
    public var isEnabled: Bool { get set }
  • Causes the text field to begin editing and presents the keyboard

    Declaration

    Swift

    override public func becomeFirstResponder() -> Bool
  • Causes the text field to stop editing and dismisses the keyboard

    Declaration

    Swift

    override public func resignFirstResponder() -> Bool
  • Clears the contents of the CVV field

    Declaration

    Swift

    @objc
    public func clear()
  • Returns an OPCvvTokenParamsProtocol instance representing the CVV entered by the user, or nil if the CVV field is not in a valid state (isValid is false)

    Important

    If the CVV is not in a valid state then the error message will get updated

    Declaration

    Swift

    @objc
    public func getCvvTokenParams() -> OPCvvTokenParamsProtocol?
  • Get the error message (if any) for this control. Error messages can be customized by providing your own errorMessageHandler

    Note

    This method functions independently of displayGeneratedErrorMessages

    Important

    Not being in a valid state does not guarantee an error message will be returned (see the ignoreUneditedFieldErrors parameter)

    Declaration

    Swift

    @objc
    public func getErrorMessage(ignoreUneditedFieldErrors: Bool = true) -> String

    Parameters

    ignoreUneditedFieldErrors

    If true (the default) an error message will only be returned if the field has been “edited”. In this context, “edited” means the field has become the first responder, had text entered, and stopped being the first responder. If false an error message will be returned without regard to whether the field has been “edited” or not.

    Return Value

    An error message that can be displayed to the user (e.g. in a custom dialog) or an empty string

  • Whether or not there is an error message that could be displayed (e.g. by the control or in a custom dialog)

    Declaration

    Swift

    @objc
    public func hasErrorMessage(ignoreUneditedFieldErrors: Bool = true) -> Bool

    Parameters

    ignoreUneditedFieldErrors

    If true (the default) an error message will only be returned if the field has been “edited”. In this context, “edited” means the field has become the first responder, had text entered, and stopped being the first responder. If false an error message will be returned without regard to whether the field has been “edited” or not.

    Return Value

    true if there is an error message that can be displayed to the user, false otherwise