KlarnaComponent
to manage payments for Klarna.
SWIFT
Copy
Ask AI
public func provideKlarnaComponent(with intent: PrimerSessionIntent) throws -> (any KlarnaComponent)? { }
Parameters
Hide Parameters
Hide Parameters
Returns
An instance ofKlarnaComponent
.
Hide KlarnaComponent
Hide KlarnaComponent
The Data associated type
Show enum KlarnaCollectableData
Show enum KlarnaCollectableData
paymentCategory
Enum member representing the payment category.
Hide Properties
Hide Properties
Payment category required for session creation.
Show child attributes
Show child attributes
KlarnaPaymentCategory
Show Properties
Show Properties
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 of the payment method category. These names are dynamic depending on what payment method is in the
category.
URL of the descriptive asset. Using this dynamic asset will make sure that changes from Klarna be automatically
propagated.
URL of the stadard asset. Using this dynamic asset will make sure that changes from Klarna be automatically
propagated.
The client token used for validation purpose.
finalizePayment
Enum member representing finalizing the Klarna payment.
The Step associated type
Show enum KlarnaStep
Show enum KlarnaStep
paymentSessionCreated(clientToken: String, paymentCategories: [KlarnaPaymentCategory])
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
The list of available Klarna payment categories.
Show child attributes
Show child attributes
KlarnaPaymentCategory
Show Properties
Show Properties
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 of the payment method category. These names are dynamic depending on what payment method is in the
category.
URL of the descriptive asset. Using this dynamic asset will make sure that changes from Klarna be automatically
propagated.
URL of the stadard asset. Using this dynamic asset will make sure that changes from Klarna be automatically
propagated.
viewInitialized
Indicates that the Klarna view has been initialized. This is the first step in the Klarna view handling process.
viewResized(height: CGFloat)
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.viewLoaded(view: UIView?)
Indicates that the Klarna view has finished loading its initial content and is ready for interaction. The
view
parameter represents the klarna view.paymentSessionAuthorized(authToken: String, checkoutData: PrimerCheckoutData)
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.paymentSessionFinalizationRequired
Signals that the payment session requires finalization step in order to be completed.
paymentSessionFinalized(authToken: String, checkoutData: PrimerCheckoutData)
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.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.Error delegate will be triggered every time an error is thrown in the process.
SWIFT
Copy
Ask AI
func didReceiveError(error: PrimerError)
Validation delegate will be triggered every time collected data is updated.
SWIFT
Copy
Ask AI
func didUpdate(validationStatus: PrimerValidationStatus, for data: PrimerCollectableData?)
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
validating
Enum case representing the ongoing validation state.
This indicates that the validation process is currently in progress.
valid
Enum case representing a successful validation state.
This indicates that the validation process has completed successfully and the data is valid.
invalid
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
An array of
PrimerValidationError
representing the specific validation errors found.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
paymentSessionCreated(clientToken: String, paymentCategories: [KlarnaPaymentCategory])
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
The list of available Klarna payment categories.
Show child attributes
Show child attributes
KlarnaPaymentCategory
Show Properties
Show Properties
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 of the payment method category. These names are dynamic depending on what payment method is in the
category.
URL of the descriptive asset. Using this dynamic asset will make sure that changes from Klarna be automatically
propagated.
URL of the stadard asset. Using this dynamic asset will make sure that changes from Klarna be automatically
propagated.
viewInitialized
Indicates that the Klarna view has been initialized. This is the first step in the Klarna view handling process.
viewResized(height: CGFloat)
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.viewLoaded(view: UIView?)
Indicates that the Klarna view has finished loading its initial content and is ready for interaction. The
view
parameter represents the klarna view.paymentSessionAuthorized(authToken: String, checkoutData: PrimerCheckoutData)
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.paymentSessionFinalizationRequired
Signals that the payment session requires finalization step in order to be completed.
paymentSessionFinalized(authToken: String, checkoutData: PrimerCheckoutData)
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
Copy
Ask AI
func didReceiveStep(step: KlarnaStep)
updateCollectedData(collectableData: KlarnaCollectableData)
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
paymentCategory
Enum member representing the payment category.
Hide Properties
Hide Properties
Payment category required for session creation.
Show child attributes
Show child attributes
KlarnaPaymentCategory
Show Properties
Show Properties
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 of the payment method category. These names are dynamic depending on what payment method is in the
category.
URL of the descriptive asset. Using this dynamic asset will make sure that changes from Klarna be automatically
propagated.
URL of the stadard asset. Using this dynamic asset will make sure that changes from Klarna be automatically
propagated.
The client token used for validation purpose.
finalizePayment
Enum member representing finalizing the Klarna payment.
SWIFT
Copy
Ask AI
func updateCollectedData(collectableData: KlarnaCollectableData)
Example
SWIFT
Copy
Ask AI
do {
manager = PrimerHeadlessUniversalCheckout.KlarnaManager()
klarnaComponent = try manager.provideKlarnaComponent(with: sessionIntent)
} catch {
// Catch errors here
}