This method allows you get an instance of KlarnaComponent to manage payments for Klarna.

1
public func provideKlarnaComponent(with intent: PrimerSessionIntent) throws -> (any KlarnaComponent)? { }
swift
copy

Parameters

primerSessionIntent
<PrimerSessionIntent>Required
Sets the session intent to be used during session creation and tokenization.

Use checkout when you want go through the checkout flow

Use vault when you want to vault a payment method, so you can use the token to pay another time.

Returns

An instance of KlarnaComponent.

KlarnaComponent
Data
KlarnaCollectableData
The Data associated type
enum KlarnaCollectableData
Enum member representing the payment category.
Properties
paymentCategory
<KlarnaPaymentCategory>
Payment category required for session creation.
Properties
identifier
StringRequired
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
name
StringRequired
Name of the payment method category. These names are dynamic depending on what payment method is in the category.
descriptiveAssetUrl
StringRequired
URL of the descriptive asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.
standardAssetUrl
StringRequired
URL of the stadard asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.
clientToken
<String?>
The client token used for validation purpose.
Enum member representing finalizing the Klarna payment.
Step
KlarnaStep
The Step associated type
enum KlarnaStep
Indicates a successful creation of a payment session. It caries `clientToken` string, which is used for validation purposes and `paymentCategories` of type `KlarnaPaymentCategory`, representing the available payment options for the user.
Properties
clientToken
<String>
paymentCategories
Array <KlarnaPaymentCategory?>
The list of available Klarna payment categories.
Properties
identifier
StringRequired
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
name
StringRequired
Name of the payment method category. These names are dynamic depending on what payment method is in the category.
descriptiveAssetUrl
StringRequired
URL of the descriptive asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.
standardAssetUrl
StringRequired
URL of the stadard asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.
Indicates that the Klarna view has been initialized. This is the first step in the Klarna view handling process.
Represents a change in the view's height, which may occur when the Klarna view adjusts to display different content. The `height` parameter specifies the new height of the view.
Properties
height
<CGFloat>
Indicates that the Klarna view has finished loading its initial content and is ready for interaction. The `view` parameter represents the klarna view.
Properties
view
<UIView?>
Indicates that the payment session has been successfully authorized. It carries an `authToken` string for subsequent operations that require authorization and `checkoutData` for showing the checkout results, after the merchant finishes the payment.
Properties
authToken
<String?>
checkoutData
<PrimerCheckoutData?>
Signals that the payment session requires finalization step in order to be completed.
Indicates that the payment session has been successfully finalized. It carries an `authToken` string for subsequent operations that require authorization and `checkoutData` for showing the checkout results, after the merchant finishes the payment.
Properties
authToken
<String?>
checkoutData
<PrimerCheckoutData?>
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.

errorDelegate
PrimerHeadlessErrorableDelegate
Error delegate will be triggered every time an error is thrown in the process.
1
func didReceiveError(error: PrimerError)
swift
copy
validationDelegate
PrimerHeadlessValidatableDelegate
Validation delegate will be triggered every time collected data is updated.
1
func didUpdate(validationStatus: PrimerValidationStatus, for data: PrimerCollectableData?)
swift
copy

PrimerValidationStatus is an enum that represents the different validation statuses in the Primer SDK. It helps to communicate the state of validation for a particular process, providing clear categorization of validation states.

enum PrimerValidationStatus
Enum case representing the ongoing validation state. This indicates that the validation process is currently in progress.
Enum case representing a successful validation state. This indicates that the validation process has completed successfully and the data is valid.
Enum case representing an unsuccessful validation state due to validation errors. This indicates that the validation process has completed but has found one or more errors in the data.
Associated Value
errors
[PrimerValidationError]
An array of `PrimerValidationError` representing the specific validation errors found.
Enum case representing an error state due to an unexpected issue. This indicates that an unexpected error has occurred during the validation process.
Associated Value
error
PrimerError
A `PrimerError` representing the unexpected error that occurred.
stepDelegate
PrimerHeadlessSteppableDelegate

Whenever start or submit methods are called, stepDelegate will trigger the next step in case the call to the mentioned method was successful.

In the case of KLARNA, the steps will be of type KlarnaStep.

KlarnaStep is an enum holding different output data for specific steps.

enum KlarnaStep
Indicates a successful creation of a payment session. It caries `clientToken` string, which is used for validation purposes and `paymentCategories` of type `KlarnaPaymentCategory`, representing the available payment options for the user.
Properties
clientToken
<String>
paymentCategories
Array <KlarnaPaymentCategory?>
The list of available Klarna payment categories.
Properties
identifier
StringRequired
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
name
StringRequired
Name of the payment method category. These names are dynamic depending on what payment method is in the category.
descriptiveAssetUrl
StringRequired
URL of the descriptive asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.
standardAssetUrl
StringRequired
URL of the stadard asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.
Indicates that the Klarna view has been initialized. This is the first step in the Klarna view handling process.
Represents a change in the view's height, which may occur when the Klarna view adjusts to display different content. The `height` parameter specifies the new height of the view.
Properties
height
<CGFloat>
Indicates that the Klarna view has finished loading its initial content and is ready for interaction. The `view` parameter represents the klarna view.
Properties
view
<UIView?>
Indicates that the payment session has been successfully authorized. It carries an `authToken` string for subsequent operations that require authorization and `checkoutData` for showing the checkout results, after the merchant finishes the payment.
Properties
authToken
<String?>
checkoutData
<PrimerCheckoutData?>
Signals that the payment session requires finalization step in order to be completed.
Indicates that the payment session has been successfully finalized. It carries an `authToken` string for subsequent operations that require authorization and `checkoutData` for showing the checkout results, after the merchant finishes the payment.
Properties
authToken
<String?>
checkoutData
<PrimerCheckoutData?>

Example:

1
func didReceiveStep(step: KlarnaStep)
swift
copy

Update component with collected data by passing an enum representing collectable data. 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 validationDelegate.

In case of KLARNA, the Data will be of type KlarnaCollectableData.

enum KlarnaCollectableData
Enum member representing the payment category.
Properties
paymentCategory
<KlarnaPaymentCategory>
Payment category required for session creation.
Properties
identifier
StringRequired
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
name
StringRequired
Name of the payment method category. These names are dynamic depending on what payment method is in the category.
descriptiveAssetUrl
StringRequired
URL of the descriptive asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.
standardAssetUrl
StringRequired
URL of the stadard asset. Using this dynamic asset will make sure that changes from Klarna be automatically propagated.
clientToken
<String?>
The client token used for validation purpose.
Enum member representing finalizing the Klarna payment.

Example:

1
func updateCollectedData(collectableData: KlarnaCollectableData)
swift
copy

Example

123456
do { manager = PrimerHeadlessUniversalCheckout.KlarnaManager() klarnaComponent = try manager.provideKlarnaComponent(with: sessionIntent)} catch { // Catch errors here}
swift
copy