CardFields
@MainActor
public struct CardFields : View
A SwiftUI view that renders a complete card entry form, including fields for card number, expiration date, and CVV. It handles input validation, card brand detection, and focus advancement between fields automatically.
-
Creates a
CardFieldsform.Declaration
Swift
@MainActor public init( authorization: String, card: BTCard, completion: @escaping (BTCardNonce?, Error?) -> Void )Parameters
authorizationA valid tokenization key or client token.
cardcompletionCalled with the resulting
BTCardNonceon success, or anErroron failure.
-
Declaration
Swift
@MainActor public var body: some View { get }
-
Registers a handler that is called whenever the form’s overall validity changes.
Use the
isValidparameter to enable or disable your submit button. When the user taps submit, call the providedsubmitclosure to tokenize the card. The merchant is responsible for providing and managing the submit button —CardFieldsdoes not include one.Declaration
Swift
@MainActor public func onValidityChange(_ handler: @escaping (Bool, @escaping () -> Void) -> Void) -> CardFieldsParameters
handlerA closure receiving the current validity state and a
submitclosure the merchant should call when their submit button is tapped.Return Value
A modified
CardFieldsview.
View on GitHub