# PaymentMethodComponent ```kotlin /* * Payment component interface */ public interface PaymentMethodComponent : AvailabilityAware, Validatable, Tokenizable { /* * The name of the payment method */ public val name: PaymentMethodName /* * Render the payment method in Composable UI. */ @Composable public fun Render() /** * Render the payment method in imperative XML/Dynamic views layouts * * @param container - Provide a view container to add the payment method */ public fun provideView(container: View): View /** * Allow to submit the payment for the payment method. * The payment submission only works for card payments. All other payment methods return `MethodNotSupportedError`. */ public suspend fun submit() /** * Checks whether the pay button is required for the payment method's state. */ public fun isPayButtonRequired(): Boolean } ``` `isAvailable()`, `isValid()`, and `tokenize()` moved out of `PaymentMethodComponent` and into three composable interfaces, each extending `BaseComponent`, so a standalone component such as the CVV component can be tokenizable without being a payment method: ```kotlin /** * Payment component interface. */ @CkoPublicApi public interface PaymentMethodComponent : AvailabilityAware, Validatable, Tokenizable { /** * Submits the payment for the payment method. */ public suspend fun submit() /** * Check if the merchant's pay button is currently required for this payment method. */ public fun isPayButtonRequired(): Boolean = true /** * Update the payment method component with new details. * * @param updateDetails The details to update the component with. * * @throws CheckoutError if the update fails. */ @Throws(CheckoutError::class) public fun update(updateDetails: UpdateDetails) } ``` `PaymentMethodComponent` still exposes `isAvailable()`, `isValid()`, and `tokenize()` in the same way, and `tokenize()` still returns `Unit` for payment methods, so existing call sites keep compiling unchanged. The CVV component implements `TokenizableComponent` instead, so `tokenize()` returns `CardCvvTokenizeResult` with no cast required. --- ### Methods #### isAvailable() Checks whether the payment method is available. > **Note** > > For the Google Pay payment method, call `isAvailable()` before `Render()` or `provideView()`. ```kotlin googlePayComponent.isAvailable() ``` #### Render() Renders Flow component in a `Compose` view. ```kotlin flowComponent.Render() ``` #### provideView() Renders the component in a `View` container. ```kotlin flowComponent.provideView(container) ``` #### 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/android/componentcallback.md#onTokenized(TokenDetails)) to retrieve the generated token and process the token details as required. ```kotlin flowComponent.tokenize() cardComponent.tokenize() ``` For the standalone CVV component, `tokenize()` returns the token directly instead: ```kotlin when (val result = cvvComponent.tokenize()) { is CardCvvTokenizeResult.Success -> Log.d("cvv", result.token) is CardCvvTokenizeResult.Failure -> Log.e("cvv", result.error.code.toString()) } ``` ### submit() Submits the payment for the payment method when using the custom pay button. The payment submission only works for card payments. All other payment methods return `MethodNotSupportedError`. ```kotlin flowComponent.submit() cardComponent.submit() ``` ### isValid Checks whether the payment method validation is successful. The payment validation only works for card payments. All other payment methods return `false`. ```kotlin flowComponent.isValid() cardComponent.isValid() ``` ### isPayButtonRequired() Checks whether the pay button is required for the payment method's current state. Defaults to `true`. Returns `false` during intermediate steps of multi-step payment methods. For example, when stc pay requests the customer's phone number. If you render your own custom pay button, call this method in the `onReady` and `onChange` callbacks to define whether to show it. ```kotlin flowComponent.isPayButtonRequired() stcPayComponent.isPayButtonRequired() ``` ### update(updateDetails: UpdateDetails) Applies the changes specified in `UpdateDetails` to the Flow for Mobile UI. For example, to modify the payment amount displayed to the customer, provide a new `amount` value in `UpdateDetails`, in [minor currency units](https://www.checkout.com/docs/payments/accept-payments/format-the-amount-value.md). > **Information** > > This only modifies the UI. To update the payment session with your changes, use the `handleSubmit` [callback](https://www.checkout.com/docs/payments/accept-payments/accept-a-payment-on-your-mobile-app/flow-for-mobile-library-reference/android/componentcallback.md#handleSubmit:_(suspend_(SessionData)_->_ApiCallResult)). ```kotlin flowComponent.update(updateDetails) cardComponent.update(updateDetails) ```