This method allows you get a new instance of KlarnaComponent
.
1 async provide ( props : KlarnaManagerProps ) : Promise < KlarnaComponent > typescript
copy
Object that provides the payment menthod type and callback functions for handling steps, errors and validation.
Properties Set the preferred session intent when showing paymentMethodType.
Called whenever the component emits a new step. This usually happens when calling start or submit or whenever the component collects data.
Parameters A type representing the created payment session.
Properties The name of this component step.
The list of available Klarna payment categories.
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.
A type that indicates that the payment view is loaded and ready to be displayed.
Properties The name of this component step.
A type representing the authorized payment session.
Properties The name of this component step.
Represents the state of the finalization.
A type representing the finalized payment session.
Properties The name of this component step.
Called to indicate that a PrimerError occurred during the component's operation.
Parameters The specific PrimerError
that occurred during the component's operation.
A unique error identifier.
A unique error code.
A error description.
A recovery suggestion for the given error. In case it's present, use it to try to recover from error.
A unique diagnostics id for the given error.
Called to indicate that the component data was considered invalid during validation.
Parameters Interface that indicates that the data has been considered invalid after validation.
Properties The data that failed validation.
Interface representing Klarna payment options required for configuring KlarnaComponent
Properties The name of this component-validatable data.
Url used by third-party Android apps to build the intent for returning to the app.
Payment category required for session creation.
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.
Properties The name of this component-validatable data.
A list of PrimerValidationError
explaining why the data is considered invalid.
Properties A unique error identifier.
A error description.
A unique diagnostics id for the given error.
Called to indicate that the component data was successfully validated.
Parameters Interface that indicates that the data has been successfully validated.
Properties The successfully validated data.
Interface representing Klarna payment options required for configuring KlarnaComponent
Properties The name of this component-validatable data.
Url used by third-party Android apps to build the intent for returning to the app.
Payment category required for session creation.
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.
Properties The name of this component-validatable data.
Called to indicate that the component data is in the process of being validated.
Parameters Interface that indicates that data is currently in the process of being validated.
Properties The data being validated.
Interface representing Klarna payment options required for configuring KlarnaComponent
Properties The name of this component-validatable data.
Url used by third-party Android apps to build the intent for returning to the app.
Payment category required for session creation.
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.
Properties The name of this component-validatable data.
Called to indicated an error that occurred during component data validation.
Parameters Interface that represents an error that occurred during the validation process.
Properties The data for which an error ocurred during validation.
Interface representing Klarna payment options required for configuring KlarnaComponent
Properties The name of this component-validatable data.
Url used by third-party Android apps to build the intent for returning to the app.
Payment category required for session creation.
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.
Properties The name of this component-validatable data.
The PrimerError
that ocurred during the validation attempt.
Properties A unique error identifier.
A unique error code.
A error description.
A recovery suggestion for the given error. In case it's present, use it to try to recover from error.
A unique diagnostics id for the given error.
An instance of KlarnaComponent
:
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.
Update component with options to use when initializing the Klarna payment view.
To validate the collected data, you can refer to the appropriate
KlarnaManagerProps
callback functions.
Parameters Interface representing Klarna payment options required for configuring KlarnaComponent
Properties The name of this component-validatable data.
Url used by third-party Android apps to build the intent for returning to the app.
Payment category required for session creation.
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.
Finalize the payment.
To validate the collected data, you can refer to the appropriate
KlarnaManagerProps
callback functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 const klarnaManagerProps : KlarnaManagerProps = { primerSessionIntent : PrimerSessionIntent . CHECKOUT , onStep : ( data : KlarnaPaymentStep ) => { switch ( data . stepName ) { case "paymentSessionCreated" : break ;
case "paymentViewLoaded" : break ;
case "paymentSessionAuthorized" : if ( data . isFinalized ) { } break ; case "paymentSessionFinalized" : break ; } } , onError : ( error : PrimerError ) => { } , onInvalid : ( data : PrimerInvalidComponentData < KlarnaPaymentValidatableData > ) => { switch ( data . data . validatableDataName ) { case 'klarnaPaymentOptions' : break ; case 'klarnaPaymentFinalization' : break ; } } , onValid : ( data : PrimerValidComponentData < KlarnaPaymentValidatableData > ) => { switch ( data . data . validatableDataName ) { case 'klarnaPaymentOptions' : break ; case 'klarnaPaymentFinalization' : break ; } } , onValidating : ( data : PrimerValidatingComponentData < KlarnaPaymentValidatableData > ) => { switch ( data . data . validatableDataName ) { case 'klarnaPaymentOptions' : break ; case 'klarnaPaymentFinalization' : break ; } } , onValidationError : ( data : PrimerComponentDataValidationError < KlarnaPaymentValidatableData > ) => { switch ( data . data . validatableDataName ) { case 'klarnaPaymentOptions' : break ; case 'klarnaPaymentFinalization' : break ; } } , } ; const klarnaManager = new KlarnaManager ( ) ; const klarnaComponent : KlarnaComponent = await klarnaManager . provide ( klarnaManagerProps ) ; typescript
copy