# Actionable ### Actionable A type alias for a component, which is: - `Describable` – It represents the component's name. - `Renderable` – The component is ready to be rendered. - `Submittable` – The component is ready to be submitted. - `Tokenizable` – The component is ready to be tokenized. ```swift public typealias Actionable = Describable & Renderable & Tokenizable & Submittable ``` ### Describable ```swift protocol Describable: Sendable { /// The name of the component. var name: String { get } } ``` ### Renderable ```swift protocol Renderable: Sendable { /// A Boolean value indicating whether the component is available. var isAvailable: Bool { get } /** Renders a view representing the component. - Returns: A view representing the component. */ @MainActor func render() -> AnyView } ``` ### Submittable ```swift protocol Submittable: Sendable { /// A Boolean value indicating whether the component validation is passed. var isValid: Bool { get } /// A Boolean value indicating whether to show the pay button for the component's current step. var isPayButtonRequired: Bool { get } /// Call to start the current payment process func submit() } ``` ### Tokenizable ```swift protocol Tokenizable: Sendable { /// The value the asynchronous `tokenize()` returns. /// /// Payment components use `Void` and report their token through the /// `onTokenized` callback. The CVV component uses /// `Result?` and returns the /// token directly. associatedtype TokenizedType /// A Boolean value indicating whether the component validation is passed. var isValid: Bool { get } /// Tokenizes the component's input and returns the result. @discardableResult func tokenize() async -> TokenizedType /// Tokenizes the component's input. The result is delivered through the /// `onTokenized` callback rather than returned. func tokenize() } ``` Components report their token in one of two ways, depending on whether they submit to Checkout.com: - Payment components, such as the card component, deliver their token through the [`onTokenized`](https://www.checkout.com/docs/payments/accept-payments/accept-a-payment-on-your-mobile-app/flow-for-mobile-library-reference/ios/componentcallback.md#onTokenized(TokenizationResult)) callback. Their asynchronous `tokenize()` returns `Void`. - The CVV component has no payment session to submit to, so its asynchronous `tokenize()` returns the token directly, as `Result?`. ## Methods ### render() Renders the component in a SwiftUI view. ```swift if component.isAvailable { component.render() } ``` ### submit() Submits a `Submittable` component, if you require your own pay button. > **Information** > > You cannot call this method for digital wallet payment methods such as Apple Pay or Google Pay. If you do, it triggers an `onError` callback. ```swift component.submit() ``` ### tokenize() Tokenizes the selected component, if supported. For payment components, use the `onTokenized()` [callback](https://www.checkout.com/docs/payments/accept-payments/accept-a-payment-on-your-mobile-app/flow-for-mobile-library-reference/ios/componentcallback.md#onTokenized(TokenizationResult)) to retrieve the generated token and process the token details as required. ```swift component.tokenize() ``` For the sessionless CVV component, call the asynchronous overload instead. It returns the token directly, rather than through a callback: ```swift switch await cvv.tokenize() { case .success(let response): print(response.token) case .failure(let error): print(error.errorCode) case .none: break } ``` --- ### isValid Checks if the `Submittable` component is ready to be submitted. The component is ready if it has: - Captured all of the required details from the customer - Passed validation ```swift component.isValid ``` ### isPayButtonRequired Indicates whether to show the pay button for the component's current step. Defaults to `true`. It returns `false` during intermediate steps of multi-step payment methods. For example, when stc pay requests the customer's phone number. ```swift component.isPayButtonRequired ```