Klarna Docs - Finalize an authorization

Finalize an authorization

Use the Klarna JavaScript SDK to finalize an authorization.

You need to finalize the authorization only if you have a multi-step checkout.

If you're integrating One Klarna and you have a multi-step checkout process we advise to authorize the purchase at the very last step in your checkout. Multi-step checkouts typically have a separated step for selecting the payment method (eg Klarna) and approving the purchase. In the payment selection step we suggest to render the Klarna widget. When the customer has proceeded to the order review page and decided to complete the purchase you should use our standard flow with an authorize call to get approval for the purchase.

In a multi-step checkout, your customer can change any order details after the payment selection step (for example, on an order review page). If you have a multi-step checkout and you authorize Klarna at the payment selection step, you might need to finalize the purchase with Klarna when your customer has reviewed the order. The authorization of the purchase must always happen at the end of the purchase when the customer clicks the Buy button.

To finalize a purchase in a multistep checkout, use the authorize call at the payment selection step and the finalize call when the customer clicks the Buy button.

Authorize() call

During the authorization step, call authorize with the auto_finalize parameter set to false. In this way, you indicate that there's an upcoming finalization step in your checkout.

JAVASCRIPT
Klarna.Payments.authorize(
{ payment_method_category: 'klarna', auto_finalize: false},
{},
function(res) {
// proceed to next checkout page. The finalize_required property in the response indicates
// if finalize is needed or not.
//
// res = {
//   show_form: true,
//   approved: true,

Sample of the authorize() for finalizing the authorization.

Finalize() call

If the response of the authorize call indicated that finalize_required is true you need to call finalize() when the consumer reaches the last page at checkout to finish the purchase. This call triggers the actual authorization and returns the authorization_token.

JAVASCRIPT
Klarna.Payments.finalize(
{payment_method_category: 'klarna'},
{},
function(res) {
// res = {
//   show_form: true,
//   approved: true,
//   authorization_token: ...
// }
})

Sample of the finalize() for finalizing the authorization.

In a successful response, you get an authorization_token to create an order. For more details about the possible responses, see Get authorization section.