KlarnaComponent to manage payments for Klarna.
SWIFT
public func provideKlarnaComponent(with intent: PrimerSessionIntent) throws -> (any KlarnaComponent)? { }
Parameters
Hide Parameters
Hide Parameters
Returns
An instance ofKlarnaComponent.
Hide KlarnaComponent
Hide KlarnaComponent
KlarnaCollectableData
The Data associated type
Show enum KlarnaCollectableData
Show enum KlarnaCollectableData
Enum member representing the payment category.
Hide Properties
Hide Properties
<KlarnaPaymentCategory>
Payment category required for session creation.
Show child attributes
Show child attributes
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.
<String?>
The client token used for validation purpose.
Enum member representing finalizing the Klarna payment.
KlarnaStep
The Step associated type
Show enum KlarnaStep
Show 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.Hide Properties
Hide Properties
Array <KlarnaPaymentCategory?>
The list of available Klarna payment categories.
Show child attributes
Show child attributes
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.
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.Indicates that the Klarna view has finished loading its initial content and is ready for interaction. The
view parameter represents the klarna view.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.Signals that the payment session requires finalization step in order to be completed.
Indicates that the payment session has been 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.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.PrimerHeadlessErrorableDelegate
Error delegate will be triggered every time an error is thrown in the process.
SWIFT
func didReceiveError(error: PrimerError)
PrimerHeadlessValidatableDelegate
Validation delegate will be triggered every time collected data is updated.
SWIFT
func didUpdate(validationStatus: PrimerValidationStatus, for data: PrimerCollectableData?)
Enum
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.Hide enum PrimerValidationStatus
Hide 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.
Hide Associated Value
Hide Associated Value
[PrimerValidationError]
An array of
PrimerValidationError representing the specific validation errors found.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.
Show enum KlarnaStep
Show 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.Hide Properties
Hide Properties
Array <KlarnaPaymentCategory?>
The list of available Klarna payment categories.
Show child attributes
Show child attributes
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.
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.Indicates that the Klarna view has finished loading its initial content and is ready for interaction. The
view parameter represents the klarna view.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.Signals that the payment session requires finalization step in order to be completed.
Indicates that the payment session has been 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.SWIFT
func didReceiveStep(step: KlarnaStep)
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
Example:
KlarnaCollectableData.Show enum KlarnaCollectableData
Show enum KlarnaCollectableData
Enum member representing the payment category.
Hide Properties
Hide Properties
<KlarnaPaymentCategory>
Payment category required for session creation.
Show child attributes
Show child attributes
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.
<String?>
The client token used for validation purpose.
Enum member representing finalizing the Klarna payment.
SWIFT
func updateCollectedData(collectableData: KlarnaCollectableData)
Example
SWIFT
do {
manager = PrimerHeadlessUniversalCheckout.KlarnaManager()
klarnaComponent = try manager.provideKlarnaComponent(with: sessionIntent)
} catch {
// Catch errors here
}