OPPaymentCardDetailsView
@objc
public class OPPaymentCardDetailsView : UIView, UIKeyInput, OPPaymentCardDetailsViewInternalDelegate, OPValidStateChangedDelegate
Convenience view for gathering card details from a user.
Important
Card details are intentionally restricted for PCI compliance-
The state of this control as an
NSDictionary
. Keys are of typeOPCardField
. Values are of typeOPCardFieldStateProtocol
Important
This property is intended mainly for compatibily with obj-c. Swift users should usefieldStates
Declaration
Swift
@objc public var fieldStatesObjc: NSDictionary { get }
-
The state of this control.
Declaration
Swift
public var fieldStates: [OPCardField : OPCardFieldStateProtocol] { get }
-
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. 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 entering valid text. Default is
.label
Declaration
Swift
@objc public var textColor: UIColor { get set }
-
The text color used when the user has entered invalid information, such as an invalid card number. Default is
.systemRed
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 cvv field. Defaults to “CVV”
Declaration
Swift
@objc @IBInspectable public var cvvPlaceholder: String? { get set }
-
Deprecated: Use
cvvPlaceholder
insteadDeclaration
Swift
@available(*, deprecated, renamed: "cvvPlaceholder") @objc @IBInspectable public var cvcPlaceholder: String? { get set }
-
The placeholder for the postal code field. Defaults to “Postal Code”
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, settingcursorColor
is identical to settingtintColor
)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
UIKeyboardAppearance.default
Declaration
Swift
public var keyboardAppearance: UIKeyboardAppearance { get set }
-
This behaves identically to setting the inputView for each child text field
Declaration
Swift
public override var inputView: UIView? { get set }
-
The custom accessory view to display when this view becomes the first responder
Declaration
Swift
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 all fields are currently in a valid state
Declaration
Swift
@objc dynamic public var isValid: Bool { get }
-
Enable/disable selecting or editing the field
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 CVV is in a valid format
Declaration
Swift
@objc public var cvvIsValid: Bool { get }
-
Deprecated: Use
cvvIsValid
insteadDeclaration
Swift
@available(*, deprecated, renamed: "cvvIsValid") @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 postal code is in a valid format. This will return
true
ifpostalCodeEntryEnabled
isfalse
Declaration
Swift
@objc public var postalCodeIsValid: Bool { get }
-
Whether or not the expiration field is empty
Declaration
Swift
@objc public var expirationIsEmpty: Bool { get }
-
Whether or not the cvv is empty
Declaration
Swift
@objc public var cvvIsEmpty: Bool { get }
-
Deprecated: Use
cvvIsEmpty
insteadDeclaration
Swift
@available(*, deprecated, renamed: "cvvIsEmpty") @objc public var cvcIsEmpty: Bool { get }
-
true
if the postal code is empty,false
otherwiseDeclaration
Swift
@objc public var postalCodeIsEmpty: Bool { get }
-
Controls if a postal code entry field will be displayed to the user. Default is
true
. Iftrue
, the type of code entry shown is controlled by the setcountryCode
value. Some country codes may result in no postal code entry being shown if those countries do not commonly use postal codes. Iffalse
, no postal code entry will ever be displayed.Important
A postal code is _required_** to process a credit card with Olo’s Ordering API. If you choose not to use the postal code field associated with this control you will need to provide your own mechanism for getting a postal code from the user.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
istrue
, this controls which type of entry is allowed. IfpostalCodeEntryEnabled
isfalse
, this property has no effect. If set tonil
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 fromNSLocale
Declaration
Swift
@objc public var countryCode: String? { get set }
-
Causes the number field to begin editing and presents the keyboard
Important
This is functionally the same as callingbecomeFirstResponder(at: .number)
Declaration
Swift
@discardableResult public override func becomeFirstResponder() -> Bool
-
Causes the specific text field to begin editing and presents the keyboard
Declaration
Swift
@discardableResult @objc public func becomeFirstResponder(at field: OPCardField) -> Bool
Parameters
field
Determins which card field to be set as first responder
-
Causes the text field to stop editing and dismisses the keyboard
Declaration
Swift
@discardableResult 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 CVV images displayed in the view for each type of card
Declaration
Swift
@objc public static var cvvImageHandler: OPCardBrandImageBlock { get set }
-
Deprecated: Use
cvvImageHandler
insteadDeclaration
Swift
@available(*, deprecated, renamed: "cvvImageHandler") @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 }
-
An optional handler for providing custom error messages that are displayed when
displayGeneratedErrorMessages
istrue
. Regardless of whether error messages are displayed or not, error messages can be retrieved by callingOPPaymentCardDetailsView.getErrorMessage(...)
Declaration
Swift
@objc public static var errorMessageHandler: OPCardErrorMessageBlock? { get set }
-
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
istrue
this will be set and cleared automatically based on user input. Iffalse
this can be used to set and clear your own messagesDeclaration
Swift
@objc public var errorMessage: String { get set }
-
Check if 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), only fields that have been edited by the user will be considered. In this context, “edited” means the user has entered text and resigned first responder status while not empty. Iffalse
, all fields will be looked at to determine an error message regardless of whether thay have been “edited”Return Value
true
if there is an error message that can be displayed to the user,false
otherwise -
Get the error message (if any) for this control. Error messages can be customized by providing your own
errorMessageHandler
Note
This method functions independently ofdisplayGeneratedErrorMessages
Important
Not being in a valid state does not guarantee an error message will be returned (see theignoreUneditedFieldErrors
parameter)Declaration
Swift
@objc public func getErrorMessage(_ ignoreUneditedFieldErrors: Bool = true) -> String
Parameters
ignoreUneditedFieldErrors
If
true
(the default), only fields that have been edited by the user will be considered. In this context, “edited” means the user has entered text and resigned first responder status while not empty. Iffalse
, all fields will be looked at to determine an error message regardless of whether thay have been “edited”Return Value
An error message that can be displayed to the user (e.g. in a custom dialog) or an empty string
-
The background color of the field
Declaration
Swift
public override var backgroundColor: UIColor? { get set }
-
The vertical alignment for the field
Declaration
Swift
@objc public var contentVerticalAlignment: UIControl.ContentVerticalAlignment { get set }
-
Delegate to receive callbacks about card input events for this view.
Declaration
Swift
@objc public var cardDetailsDelegate: OPPaymentCardDetailsViewDelegate?
-
Returns an
OPPaymentMethodParamsProtocol
instance representing the card details.Important
If the CVV is not in a valid state (isValid
isfalse
) then the error message will get updatedDeclaration
Swift
@objc public func getPaymentMethodParams() -> OPPaymentMethodParamsProtocol?