This guide provides detailed instructions to install the cartridge on Salesforce Commerce Cloud (SFCC) SFRA stores.
The Klarna Payments LINK Cartridge contains two cartridges required for full functionality. Controller and SFRA support are separated into two distinct cartridges, facilitating the installation and use of either model:
int_klarna_payments
: Implements the core storefront functionality.int_klarna_payments_sfra
: Implements the storefront functionality with SFRA code.1. Import the int_klarna_payments
cartridge into the SCC Studio Workspace:
int_klarna_payments
cartridge.2. Import the int_klarna_payments_sfra
cartridge into the SCC Studio Workspace:
int_klarna_payments_sfra
cartridge.3. Prepend the Klarna cartridges to the effective site cartridge path:
int_klarna_payments_sfra:int_klarna_payments
to the Cartridges field.site-template.zip
installation package.site-template.zip
.Review the default service.xml
file in the site-template.zip
and update the configuration for Playground and Production accordingly before importing.
Update the path to your base SFRA installation in the package.json
file from the same root folder if necessary.
Ensure the correct path to the SFRA cartridge is configured.
Run the following commands from the root folder of the Klarna repository:
npm run compile:scss
to compile the SCSS files.npm run compile:js
to build the Klarna-specific JavaScript files.As of version 24.4.0, the cartridge configuration process has changed. If you are using a version older than 24.4.0, please refer to the Deprecated Features section of the Changelog for detailed information on the configuration changes.
client_id
to activate OSM and KEC.Controller | Start Node | Remarks |
---|---|---|
Checkout.js | Begin | Extended to call Klarna session manager |
CheckoutServices.js | Get, SubmitPayment, PlaceOrder | Klarna payment method/category and totals are being stored |
CheckoutShippingServices.js | SubmitShipping, ToggleMultiShipping | Calling the Klarna session manager |
Order.js | Confirm | Extending Klarna order data to view data |
The templates have been updated to support On-site Messaging and Address Forms for Klarna. These templates are intended for reference, but you can customize them to suit your specific needs. Please ensure that the final review and sign-off align with your project requirements and contractual agreements.
This one-time clean-up job is applicable only to merchants integrated with Klarna Payments cartridge version earlier than 19.1.6, utilizing (or previously used) virtual card-based settlement (VCN) and stored decrypted card details within Business Manager.
The job iterates over orders with status Exported
and the attribute custom.kpIsVCN=true
to remove sensitive details saved in fields kpVCNPAN
, kpVCNCSC
, kpVCNExpirationMonth
, and kpVCNExpirationYear
from previous releases. No parameters are passed to the script.
Upon successful run, the job logs the result of processed orders in the custom debug log located in webdav/Sites/Logs
. You will receive a message indicating the processed orders count for each storefront or a message indicating that there are no orders needing update.
In case of an error, the cause of the failure (message and stack trace) will be logged in the standard error log.
Ensure that you have access to the SFCC Business Manager and that the jobs.xml
configuration file is prepared and accessible.
Log into the SFCC Business Manager, and go to Administration > Operations > Import & Export.
Click on the Import button, and browse for the jobs.xml
file and select it for import.
The default scope included in the XML file is for RefArch. If you have multiple sites using this functionality, you need to configure each site as a separate flow within this file.
After the job import is complete, navigate to the flow section within the job, and scroll down to the bottom of the current flow.
Click on the Add a sequential flow button. This action will create a new flow under the current job configuration.
In the newly added flow, click on the Configure a step button. When the flyout appears, search for the term script, and select the ExecuteScriptModule
from the list.
Enter the step details:
OrderCleanUpJob.js
file. The default path is int_klarna_payments/cartridge/scripts/job/OrderCleanUpJob.js
, but this can vary depending on where the script is placed.Click on the Assign button to save the step configuration.
Repeat steps 1-5 for each site/storefront that you have using Klarna VCN and need additional configuration. This ensures that the clean-up job runs for all relevant sites and removes sensitive data as required.
The RecurringOrders
job is designed to process subscription entries for all customers. The job performs the following functions:
nextChargeDate
or nextRetryDate
matches the current date.Configuration
By default, the job is set to run on the RefArch site, as specified in the jobs.xml
file. This setting can be modified either in the jobs.xml
file or through the storefront configuration.
The job consists of a single step, createOrder
, with the following configuration:
int_klarna_payments/cartridge/scripts/job/RecurringOrdersJob.js
execute
The job operates at site level.
Ensure your configuration matches these details to maintain the proper functionality of the RecurringOrders job.
The Storefront Reference Architecture (SFRA) does not require modifications to the core cartridge to enable any of the LINK integration cartridges. The int_klarna_payments_sfra
cartridge follows Salesforce's best practices. Below are two cases where changes may be applicable:
app_storefront_base\cartridge\client\default\js\checkout\checkout.js
After placing an order, every customer is redirected to Klarna and then sent back to the site with the order confirmation page. To prevent sending any additional URL parameters to Klarna, follow these steps:
app_storefront_base\cartridge\client\default\js\cart\cart.js
To get updates for the cart On-Site Messaging (OSM) widget, make the following changes in cart.js or in your app cartridge.
In the updateCartTotals(data) function, add the following code at the bottom:
Ensure these modifications are implemented to maintain proper integration with Klarna's services.
This section is relevant if there are other payment cartridge integrations within the cartridge path besides Klarna Payments SFRA. Regardless of the order of those cartridges in the cartridge path, certain templates need to be overwritten by adding a new if condition and including the correct sub-template. The templates that require modifications are:
\templates\default\checkout\billing\paymentOptions\paymentOptionsContent.isml
\templates\default\checkout\billing\paymentOptions\paymentOptionsSummary.isml
\templates\default\checkout\billing\paymentOptions\paymentOptionsTabs.isml
If the website owner requires PayPal as well as Klarna, each of these templates must be copied to a new custom cartridge. The example below shows the new code for the paymentOptionsContent.isml
template:
The same applies to the other two templates (paymentOptionsSummary.isml
and paymentOptionsTabs.isml
).
All requests are made through Klarna’s REST API and are encrypted using SHA-256 with the shared secret provided by Klarna. Only HTTPS is allowed, and JSON is used for all communications.
For a full reference guide, along with the resource structure for requests and responses, refer to Klarna Payments API.