KlarnaComponent to manage payments for Klarna.
KOTLIN
fun provideKlarnaComponent(primerSessionIntent: PrimerSessionIntent): KlarnaComponent
Parameters
Hide Parameters
Hide Parameters
PrimerSessionIntent
required
Sets the session intent to be used during session creation and tokenization.
Returns
An instance ofKlarnaComponent.
Hide KlarnaComponent
Hide KlarnaComponent
Initialize the component by calling the start function. This method should be called only once.
Call
submit function in order to process collected data and move component to next state.Get a Flow
of PrimerError objects that represent errors emitted by this component.
Subscribers can observe and handle errors using this Flow.
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
and receive the validation status when it’s updated.
Show sealed interface KlarnaPaymentCollectableData
Show sealed interface KlarnaPaymentCollectableData
A data class representing the step of choosing a Klarna Payment method.
Hide Properties
Hide Properties
Context
Context required for the creation of the payment view.
String
Url used by third-party apps to build the intent for returning to the app.
KlarnaPaymentCategory
Payment category required for session creation.
Show Properties
Show Properties
Show Properties
Show Properties
String
required
ID of the payment method category to be used while loading the payment view. The possible values are:
- klarna
- pay_later
- pay_now
- pay_over_time
- direct_bank_transfer
- direct_debit
String
required
Name of the payment method category. These names are dynamic depending on what payment method is in the category.
String
required
URL of the descriptive asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.
String
required
URL of the stadard asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.
Object representing the step of finalizing the Klarna payment.
KlarnaPaymentStep is a class holding different output data for specific steps. Whenever
start or submit methods are
called, componentStep will trigger the next step in case the call to the mentioned method was successful.
Show sealed interface KlarnaPaymentStep
Show sealed interface KlarnaPaymentStep
A data class representing the created payment session.
Hide Properties
Hide Properties
List<KlarnaPaymentCategory>
The list of available Klarna payment categories.
Show Properties
Show Properties
Show Properties
Show Properties
String
required
ID of the payment method category to be used while loading the payment view. The possible values are:
- klarna
- pay_later
- pay_now
- pay_over_time
- direct_bank_transfer
- direct_debit
String
required
Name of the payment method category. These names are dynamic depending on what payment method is in the category.
String
required
URL of the descriptive asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.
String
required
URL of the stadard asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.
A data class holding the Klarna payment view.
Hide Properties
Hide Properties
PrimerKlarnaPaymentView
The Klarna payment view.
A data class representing the authorized payment session.
Hide Properties
Hide Properties
Boolean
The state of the finalization.
Object representing the finalized payment session.
The
PrimerValidationStatus interface encompasses a range of validation statuses.Show sealed interface PrimerValidationStatus
Show sealed interface PrimerValidationStatus
Indicates that data is currently in the process of being validated.
Hide Properties
Hide Properties
The data being validated.
Indicates that the data has successfully been validated.
Hide Properties
Hide Properties
The successfully validated data.
Indicates that the data has been considered invalid after validation.
Hide Properties
Hide Properties
List<PrimerValidationError>
The data that failed validation.
Represents the status when an error occurred during the validation process.
Hide Properties
Hide Properties
PrimerError
The specific
PrimerError that occurred during validation.The data for which the error occurred.
Example
KOTLIN
class CheckoutActivity : AppCompatActivity() {
// 👇 Add this
private val klarnaComponent by lazy {
PrimerHeadlessUniversalCheckoutKlarnaManager(viewModelStoreOwner = this)
.provideKlarnaComponent(primerSessionIntent = PrimerSessionIntent.CHECKOUT)
}
}