> ## Documentation Index
> Fetch the complete documentation index at: https://primer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# provideKlarnaComponent

This method allows you get a new instance of `KlarnaComponent` to manage payments for Klarna.

```kotlin KOTLIN theme={"dark"}
fun provideKlarnaComponent(primerSessionIntent: PrimerSessionIntent): KlarnaComponent
```

## Parameters

**Parameters**

**primerSessionIntent** `PrimerSessionIntent` *required*

Sets the session intent to be used during session creation and tokenization.

**Properties**

**PrimerSessionIntent.CHECKOUT**

**PrimerSessionIntent.VAULT**

## Returns

An instance of `KlarnaComponent`.

**KlarnaComponent**

**start()**

Initialize the component by calling the start function. This method should be called only once.

**submit()**

Call `submit` function in order to process collected data and move component to next state.

**componentError: Flow\<PrimerError>**

Get a [Flow](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/)
of [PrimerError](https://primer.io/docs/sdk/android/v2.x.x/common-objects/PrimerError.md) objects that represent errors emitted by this component.
Subscribers can observe and handle errors using this Flow.

**updateCollectedData(collectableData: KlarnaPaymentCollectableData)**

Update component with collected data by passing implementations of sealed interface.
This method can be called at any point, even if you have only partially collected data.
To validate the partially collected data, you can refer to the
[componentValidationStatus](#component-validation-status-flow-primer-validation-status-klarna-payment-collectable-data)
and receive the validation status when it's updated.

**sealed interface KlarnaPaymentCollectableData**

**PaymentOptions**

A data class representing the step of choosing a Klarna Payment method.

**Properties**

**context** `Context`

Context required for the creation of the payment view.

**returnIntentUrl** `String`

Url used by third-party apps to build the intent for returning to the app.

**paymentCategory** `KlarnaPaymentCategory`

Payment category required for session creation.

**Properties**

**KlarnaPaymentCategory**

**Properties**

**identifier** `String` *required*

ID of the payment method category to be used while loading the payment view. The possible values are:

<ul>
  <li>klarna</li>
  <li>pay\_later</li>
  <li>pay\_now</li>
  <li>pay\_over\_time</li>
  <li>direct\_bank\_transfer</li>
  <li>direct\_debit</li>
</ul>

**name** `String` *required*

Name of the payment method category. These names are dynamic depending on what payment method is in the category.

**descriptiveAssetUrl** `String` *required*

URL of the descriptive asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.

**standardAssetUrl** `String` *required*

URL of the stadard asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.

**FinalizePayment**

Object representing the step of finalizing the Klarna payment.

**componentStep: Flow\<KlarnaPaymentStep>**

`KlarnaPaymentStep` is a class holding different output data for specific steps. Whenever&#x20;
[start](#param-start) or [submit](#param-submit) methods are
called, `componentStep` will trigger the next step in case the call to the mentioned method was successful.

**sealed interface KlarnaPaymentStep**

**PaymentSessionCreated**

A data class representing the created payment session.

**Properties**

**paymentCategories** `List\<KlarnaPaymentCategory\>`

The list of available Klarna payment categories.

**Properties**

**KlarnaPaymentCategory**

**Properties**

**identifier** `String` *required*

ID of the payment method category to be used while loading the payment view. The possible values are:

<ul>
  <li>klarna</li>
  <li>pay\_later</li>
  <li>pay\_now</li>
  <li>pay\_over\_time</li>
  <li>direct\_bank\_transfer</li>
  <li>direct\_debit</li>
</ul>

**name** `String` *required*

Name of the payment method category. These names are dynamic depending on what payment method is in the category.

**descriptiveAssetUrl** `String` *required*

URL of the descriptive asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.

**standardAssetUrl** `String` *required*

URL of the stadard asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.

**PaymentViewLoaded**

A data class holding the Klarna payment view.

**Properties**

**paymentView** `PrimerKlarnaPaymentView`

The Klarna payment view.

**PaymentSessionAuthorized**

A data class representing the authorized payment session.

**Properties**

**isFinalized** `Boolean`

The state of the finalization.

**PaymentSessionFinalized**

Object representing the finalized payment session.

**componentValidationStatus: Flow\<PrimerValidationStatus\<KlarnaPaymentCollectableData>>**

The `PrimerValidationStatus` interface encompasses a range of validation statuses.

**sealed interface PrimerValidationStatus**

**Validating\<KlarnaPaymentCollectableData>**

Indicates that data is currently in the process of being validated.

**Properties**

**collectableData** `KlarnaPaymentCollectableData`

The data being validated.

**Valid\<KlarnaPaymentCollectableData>**

Indicates that the data has successfully been validated.

**Properties**

**collectableData** `KlarnaPaymentCollectableData`

The successfully validated data.

**Invalid\<KlarnaPaymentCollectableData>**

Indicates that the data has been considered invalid after validation.

**Properties**

**validationErrors** `List\<PrimerValidationError\>`

List of `PrimerValidationError` objects that represent data validation errors emitted by this component.

**PrimerValidationError**

**List\<PrimerValidationError>**

**Type**

**PrimerValidationError**

**Properties**

**errorId** `String` *required*

A unique error identifier.

**description** `String` *required*

A error description.

**diagnosticsId** `String` *required*

A unique diagnostics id for the given error.

**collectableData** `KlarnaPaymentCollectableData`

The data that failed validation.

**Error\<KlarnaPaymentCollectableData>**

Represents the status when an error occurred during the validation process.

**Properties**

**error** `PrimerError`

The specific `PrimerError` that occurred during validation.

**PrimerValidationError**

**errorId** `String` *required*

A unique error identifier.

**errorCode** `String?`

A unique error code.

**description** `String` *required*

A error description.

**recoverySuggestion** `String?`

A recovery suggestion for the given error. In case it's present, use it to try
to recover from error.

**diagnosticsId** `String` *required*

A unique diagnostics id for the given error.

**collectableData** `KlarnaPaymentCollectableData`

The data for which the error occurred.

## Example

```kotlin KOTLIN theme={"dark"}
class CheckoutActivity : AppCompatActivity() {
  // 👇 Add this
  private val klarnaComponent by lazy {
	PrimerHeadlessUniversalCheckoutKlarnaManager(viewModelStoreOwner = this)
            .provideKlarnaComponent(primerSessionIntent = PrimerSessionIntent.CHECKOUT)
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.