This section covers the installation, configuration, and management of the Klarna Payments App in VTEX. It includes step-by-step instructions for setting up Klarna as a payment provider, handling orders, and moving to production.
The Klarna Payments App integrates with VTEX, enabling Klarna as a payment option at checkout. This allows merchants to accept payments through Klarna and manage orders using basic Order Management functionalities, such as capturing payments, processing refunds, and canceling transactions.
The following diagram provide a detailed overview of how Klarna Payments functions within the VTEX platform.
sequenceDiagram
title Klarna Payments App for VTEX
participant Customer
participant VTEX_Storefront
participant KP_App
participant Klarna
participant VTEX_Back_Office
Customer->>VTEX_Storefront: 1. Goes to checkout and clicks "Buy"
VTEX_Storefront->>KP_App: 2. Sends basket and customer information
KP_App->>Klarna: 3. Calls `create session` API
Klarna-->>KP_App: 4. Returns `session_id`
KP_App->>Klarna: 5. Creates `HPP session` using `session_id`
Note right of KP_App: `place_order_mode = PLACE_ORDER`
Klarna-->>KP_App: 6. Returns `HPP URL`
KP_App->>Customer: 7. Redirects to Klarna Hosted Payment Page (HPP)
Customer->>Klarna: 8. Authenticates & authorizes payment
Klarna-->>KP_App: 9. Sends notification to `merchant_urls`
alt **Successful authorization**
Note over Klarna, KP_App: Contains `session_id`, `status`, and `order_id`
KP_App->>VTEX_Back_Office: 10. Sends order data for order creation
VTEX_Back_Office->>VTEX_Storefront: 11. Creates VTEX order
KP_App->>VTEX_Storefront: 12. Redirects customer to VTEX
VTEX_Storefront->>Customer: 13. Displays order confirmation message
else **Failed authorization**
Note over Klarna, KP_App: Contains `session_id` and `status`
KP_App->>VTEX_Storefront: 10. Redirects customer to VTEX
VTEX_Storefront->>Customer: 11. Displays error message
end
Go to VTEX Admin > Store Settings > Payments > Providers and click New Provider
Adding Klarna as payment provider on VTEX
Search and select KlarnaPayments.
Select Klarna Payments as provider
Enter the required credentials:
Application Key (API User)
Application Token (API Password)
Entering Klarna API credentials on VTEX
Enter a name for you to easily identify the Klarna provider configuration.
Enter an easy to identify name to the Klarna provider configuration
The Enable test mode setting determines whether the provider configuration applies to the VTEX test environment or the VTEX production environment.
Enable test mode - Provider configuration -VTEX
Click Save to complete the setup.
*Important!*Ensure that the Klarna credentials entered in the provider configuration match the Klarna environment selected in the Klarna Payments App. Using Playground credentials with the Production environment, or vice versa, will result in authentication errors.
Testing is a crucial step in ensuring that the Klarna Payments App functions correctly on the VTEX platform. It's recommended to conduct thorough testing in the Playground environment, in test mode, before going live.