KlarnaComponent
.
async provide(props: KlarnaManagerProps): Promise<KlarnaComponent>
Hide Parameters
Show Properties
Show Parameters
Show Properties
Show child attributes
Show Properties
Show Properties
PrimerCheckoutData
if the error occurs after the payment creation.override
this method, you must call the errorHandler
to finalize the flow.Show Properties
Hide Properties
Show Properties
payment-failed
which is an error from the PSP side, or cancelled-by-customer
which means the failure initiated on the customer side. I.e. cancelling a 3DS flow.Show Variations
Show Parameters
Show Properties
Show child attributes
Show Properties
Show Properties
PrimerValidationError
explaining why the data is considered invalid.Show Parameters
Show Properties
Show child attributes
Show Properties
Show Properties
Show Parameters
Show Properties
Show child attributes
Show Properties
Show Properties
Show Parameters
Show Properties
Show child attributes
Show Properties
Show Properties
PrimerError
that ocurred during the validation attempt.Show Properties
KlarnaComponent
:
Hide KlarnaComponent
start
function. This method should be called only once.submit
function in order to process collected data and move component to next state.Show Parameters
Show Properties
Show Properties
// 👇 Add this
const klarnaManagerProps: KlarnaManagerProps = {
primerSessionIntent: PrimerSessionIntent.CHECKOUT,
onStep: (data: KlarnaPaymentStep) => {
// Show loading indicator, render categories or finalize payment.
switch (data.stepName) {
case "paymentSessionCreated":
// Render categories
break;
case "paymentViewLoaded":
// Render payment view
break;
case "paymentSessionAuthorized":
if (data.isFinalized) {
// Finalize payment
}
break;
case "paymentSessionFinalized":
// ...
break;
}
},
onError: (error: PrimerError) => {
// An error that occurred during the component's operation.
},
onInvalid: (
data: PrimerInvalidComponentData<KlarnaPaymentValidatableData>
) => {
// Data was considered invalid during validation.
switch (data.data.validatableDataName) {
case "klarnaPaymentOptions":
// ...
break;
case "klarnaPaymentFinalization":
// ...
break;
}
},
onValid: (data: PrimerValidComponentData<KlarnaPaymentValidatableData>) => {
// Data was successfully validated.
switch (data.data.validatableDataName) {
case "klarnaPaymentOptions":
// ...
break;
case "klarnaPaymentFinalization":
// ...
break;
}
},
onValidating: (
data: PrimerValidatingComponentData<KlarnaPaymentValidatableData>
) => {
// Data is in the process of being validated.
switch (data.data.validatableDataName) {
case "klarnaPaymentOptions":
// ...
break;
case "klarnaPaymentFinalization":
// ...
break;
}
},
onValidationError: (
data: PrimerComponentDataValidationError<KlarnaPaymentValidatableData>
) => {
// Error occurred during data validation.
switch (data.data.validatableDataName) {
case "klarnaPaymentOptions":
// ...
break;
case "klarnaPaymentFinalization":
// ...
break;
}
},
};
const klarnaManager = new KlarnaManager();
const klarnaComponent: KlarnaComponent = await klarnaManager.provide(
klarnaManagerProps
);