OPPaymentCardDetailsView

@objc
public class OPPaymentCardDetailsView : UIView, UIKeyInput, OPPaymentCardDetailsViewInternalDelegate

Convenience view for gathering card details from a user.

Important

Card details are intentionally restricted for PCI compliance
  • The font used in each child field. Default is UIFont.systemFont(ofSize:18)

    Declaration

    Swift

    @objc
    public var font: UIFont { get set }
  • The font used for error text

    Declaration

    Swift

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

    Declaration

    Swift

    @objc
    public var textColor: UIColor { get set }
  • The text color to be used when the user has entered invalid information, such as an invalid card number. Default is .red

    Declaration

    Swift

    @objc
    public var textErrorColor: UIColor { get set }
  • The text placeholder color used in each child field. This will also set the color of the card placeholder icon. Default is .systemGray2

    Declaration

    Swift

    @objc
    public var placeholderColor: UIColor { get set }
  • The placeholder for the card number field. Default is “4242424242424242”. If this is set to something that resembles a card number, it will automatically format it as such (in other words, you don’t need to add spaces to this string)

    Declaration

    Swift

    @objc
    @IBInspectable
    public var numberPlaceholder: String? { get set }
  • The placeholder for the expiration field. Defaults to “MM/YY”

    Declaration

    Swift

    @objc
    @IBInspectable
    public var expirationPlaceholder: String? { get set }
  • The placeholder for the cvc field. Defaults to “CVC”

    Declaration

    Swift

    @objc
    @IBInspectable
    public var cvcPlaceholder: String? { get set }
  • The placeholder for the postal code field. Defaults to “ZIP” for United States or “Postal” for all other country codes

    Declaration

    Swift

    @objc
    @IBInspectable
    public var postalCodePlaceholder: 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, calling setCursorColor is identical to calling setTintColor)

    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 keyboard appearance for the field. Default is UIKeyboardAppearanceDefault

    Declaration

    Swift

    @objc
    public var keyboardAppearance: UIKeyboardAppearance { get set }
  • This behaves identically to setting the inputView for each child text field

    Declaration

    Swift

    @objc
    public override var inputView: UIView? { get set }
  • This behaves identically to setting the inputAccessoryView for each child text field

    Declaration

    Swift

    @objc
    public override var inputAccessoryView: UIView? { get set }
  • The curent brand image displayed in the receiver

    Declaration

    Swift

    @objc
    public var brandImage: UIImage? { get }
  • Whether or not the form currently contains a valid card number, expiration date, CVC, and postal code (if required)

    Declaration

    Swift

    @objc
    dynamic public var isValid: Bool { get }
  • Enable/disable selecting or editing the field. Useful when submitting card details to Olo

    Declaration

    Swift

    @objc
    public var isEnabled: Bool { get set }
  • The detected brand of the card, based on the user’s input

    Declaration

    Swift

    @objc
    public var cardType: OPCardBrand { get }
  • Whether or not the card number field is valid

    Declaration

    Swift

    @objc
    public var cardNumberIsValid: Bool { get }
  • Whether or not the expiration field is valid

    Declaration

    Swift

    @objc
    public var expirationIsValid: Bool { get }
  • Whether or not the expiration month is valid

    Declaration

    Swift

    @objc
    public var expirationMonthIsValid: Bool { get }
  • Whether or not the expiration year is valid

    Declaration

    Swift

    @objc
    public var expirationYearIsValid: Bool { get }
  • Whether or not the CVC is valid

    Declaration

    Swift

    @objc
    public var cvcIsValid: Bool { get }
  • Whether or not the card number field is empty

    Declaration

    Swift

    @objc
    public var cardNumberIsEmpty: Bool { get }
  • Whether or not the expiration field is empty

    Declaration

    Swift

    @objc
    public var expirationIsEmpty: Bool { get }
  • Whether or not the expiration month is empty

    Declaration

    Swift

    @objc
    public var expirationMonthIsEmpty: Bool { get }
  • Whether or not the expiration year is empty

    Declaration

    Swift

    @objc
    public var expirationYearIsEmpty: Bool { get }
  • Whether or not the cvc is empty

    Declaration

    Swift

    @objc
    public var cvcIsEmpty: Bool { get }
  • true if the postal code is empty, false otherwise

    Declaration

    Swift

    @objc
    public var postalCodeIsEmpty: Bool { get }
  • Controls if a postal code entry field can be displayed to the user. Default is YES. If YES, the type of code entry shown is controlled by the set countryCode value. Some country codes may result in no postal code entry being shown if those countries do not commonly use postal codes. If NO, no postal code entry will ever be displayed

    Declaration

    Swift

    @objc
    public var postalCodeEntryEnabled: Bool { get set }
  • The two-letter ISO country code that corresponds to the user’s billing address. If postalCodeEntryEnabled is YES, this controls which type of entry is allowed. If postalCodeEntryEnabled is NO, this property currently has no effect. If set to nil and postal code entry is enabled, the country from the user’s current locale will be filled in. Otherwise the specific country code set will be used. By default this will fetch the user’s current country code from NSLocale

    Declaration

    Swift

    @objc
    public var countryCode: String? { get set }
  • Causes the text field to begin editing. Presents the keyboard

    Declaration

    Swift

    @discardableResult
    @objc
    public override func becomeFirstResponder() -> Bool
  • Causes the text field to stop editing. Dismisses the keyboard

    Declaration

    Swift

    @discardableResult
    @objc
    public override func resignFirstResponder() -> Bool
  • Resets all of the contents of all of the fields. If the field is currently being edited, the number field will become selected

    Declaration

    Swift

    @objc
    public func clear()
  • Use this to customize CVC images displayed in the view for each type of card

    Declaration

    Swift

    @objc
    public static var cvcImageHandler: OPCardBrandImageBlock { get set }
  • Use this to customize card images displayed in the view for each type of card

    Declaration

    Swift

    @objc
    public static var brandImageHandler: OPCardBrandImageBlock { get set }
  • Use this to customize error images displayed in the view for each type of card

    Declaration

    Swift

    @objc
    public static var errorImageHandler: OPCardBrandImageBlock { get set }
  • Use this to customize the error messages that are displayed when displayGeneratedErrorMessages is true

    Declaration

    Swift

    @objc
    public static var errorMessageHandler: OPCardErrorMessageBlock
  • Whether or not the 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 set to true this will be set and cleared automatically based on user input. If false this can be used to set and clear your own messages

    Declaration

    Swift

    @objc
    public var errorMessage: String { get set }
  • Default error message handler for getting user facing error messages for this control.

    Declaration

    Swift

    @objc
    public static func getErrorMessage(for control: OPPaymentCardDetailsView, with field: OPCardField) -> String

    Parameters

    control

    The instance of the control to get an error message for

    field

    The field to get an error message for

    Return Value

    An error message for the given control and field if it’s in an invalid state, or an empty string if there is no error

  • Returns the rectangle in which the receiver draws its brand image.

    Declaration

    Swift

    @objc(brandImageRectForBounds:)
    public func brandImageRect(forBounds bounds: CGRect) -> CGRect

    Parameters

    bounds

    The bounding rectangle of the receiver.

    Return Value

    the rectangle in which the receiver draws its brand image.

  • Returns the rectangle in which the receiver draws the text fields.

    Declaration

    Swift

    @objc(fieldsRectForBounds:)
    public func fieldsRect(forBounds bounds: CGRect) -> CGRect

    Parameters

    bounds

    The bounding rectangle of the receiver.

    Return Value

    The rectangle in which the receiver draws the text fields.

  • The background color of the field

    Declaration

    Swift

    @objc
    public override var backgroundColor: UIColor? { get set }
  • The vertical alignment for the field

    Declaration

    Swift

    @objc
    public var contentVerticalAlignment: UIControl.ContentVerticalAlignment { get set }
  • Delegate for callbacks related to text editing begin and end

    Declaration

    Swift

    @objc
    public var cardDetailsDelegate: OPPaymentCardDetailsViewDelegate?
  • Returns the OPPaymentMethodParams object representing the details in the form.

    Throws

    OPError if the card details are not valid

    Declaration

    Swift

    @objc
    public func getPaymentMethodParams() throws -> OPPaymentMethodParamsProtocol
  • Runs validation on the card details.

    Declaration

    Swift

    @objc
    public func validateCardDetails() -> OPError?
  • Gets a user-facing message for the given card field

    Declaration

    Swift

    @objc
    public func getUserFacingMessage(with field: OPCardField) -> String

    Parameters

    field

    The field to get an error for