This guide will help you install Klarna add-ons for SAP Commerce Suite to enable Klarna payment solutions. Follow the steps outlined below to ensure a successful installation.
9 min read<HYBRIS_HOME>/bin/custom
:klarnapaymentaddon
klarnapayment
klarnapaymentapi
klarnapaymentbackoffice
klarnapaymentb2baddon
.1. Verify existing extensions: Ensure addonsupport
is present:
<extension name="addonsupport" />
2. Add Klarna extensions:
<extension name="klarnapaymentaddon" />
<extension name="klarnapayment" />
<extension name="klarnapaymentbackoffice" />
<extension name="klarnapaymentapi" />
For B2B, add:
<extension name="klarnapaymentb2baddon" />
Ctrl+C
.hybrisserver.bat stop
./hybrisserver.sh stop
<HYBRIS_HOME>/bin/platform
and run:setantenv.bat
./setantenv.sh
ant addoninstall -Daddonnames="klarnapaymentaddon" -DaddonStorefront.yacceleratorstorefront="yacceleratorstorefront"
ant addoninstall -Daddonnames="klarnapaymentb2baddon" -DaddonStorefront.yacceleratorstorefront="yb2bacceleratorstorefront"
Note: Depending on your SAP Commerce version, you might need to install liveeditaddon
and b2ccheckoutaddon
. Verify the storefront name for your project.
Verify these extensions are present:
addonsupport
klarnapaymentaddon
klarnapayment
klarnapaymentapi
klarnapaymentbackoffice
klarnapaymentb2baddon
Verify storefront integration: Confirm the target storefront extension is listed.
Add the following configurations to project.properties
in the klarnapayment
extension:
klarnapayment.merchant.url.confirmation=
https://<your_host>/klarna/order/confirmation
klarnapayment.merchant.url.notification=
https://<your_host>/klarna/payment/checkout/pending-update
klarnacheckout.merchant.url.authorization=
https://<your_host>/klarna/payment/auth-callback
For site-specific configurations:
klarnapayment.merchant.url.confirmation.<siteuid>=
https://<your_host>/klarna/order/confirmation
klarnapayment.merchant.url.notification.<siteuid>=
https://<your_host>/klarna/payment/checkout/pending-update
klarnacheckout.merchant.url.authorization.<site_uid>=
https://<your_host>/klarna/payment/auth-callback
Add this to local.properties
:
csrf.allowed.url.patterns=/[^/]+(/[^?]*)+(sop/response)$,/[^/]+(/[^?]*)+(merchant_callback)$,/[^/]+(/[^?]*)+(hop/response)$,/[^/]+(/[^?]*)+(language)$,/[^/]+(/[^?]*)+(currency)$,/[^/]+(/[^?]*)+(push)$,/[^/]+(/[^?]*)+(pending-update)$,/[^/]+(/[^?]*)+(confirmation)$,/[^/]+(/[^?]*)+(auth-callback)$
Configure email settings in local.properties
:
mail.from=<your_email>
mail.replyto=<your_email>
mail.smtp.server=<your_mail_server>
mail.smtp.port=<your_mail_port>
mail.smtp.user=<your_email>
mail.smtp.password=<your_password>
mail.use.tls=true
For efficient support and issue identification we highly recommend to set user-agent and region-specific settings:
shoporplatform=<your_platform> # Example: SAP_Comm
platformversion=<your_platform_version> # Example: 1905
modulename=<your_module> # Example: KP
moduleversion=<your_module_version> # Example: 9.0
Configure the Market and the Region specific to each site:
klarna.market.country.<site_id>=<market_code>
# E.g. klarna.market.country.apparel-uk=GB
klarna.market.region.<site_id>=<region_code>
# E.g. klarna.market.region.apparel-uk=EU
If multiple currencies are applicable on the merchant site, ensure that the out-of-box settings for the conversion factor and delivery cost are properly configured. These values are used to send the cost in the purchased currency converted value to Klarna.
Adjust these configurations based on your specific project requirements to ensure smooth operation and support from Klarna.
When an order is successfully processed by Klarna but the placement fails in SAP, an email notification is sent to the merchant. The recipient's email address is configured in the Klarna settings within the back office. The email content for this notification is managed using the FailedOrder_Email_Template.impex
file, located in \klarnapayment\resources\klarnapayment\email_impex\
. This impex file must be loaded after the server starts. Merchants have the flexibility to modify the email content, specifically the CMS component OrderFailedEmailBody
, either by editing the impex file or through the back office at a later time.
Add this tag to the Merchant Payment JSP (e.g., silentOrderPostPage.jsp
):
<%@ taglib prefix="klarnapayment" tagdir="/WEB-INF/tags/addons/klarnapaymentaddon/responsive/" %>
...
<klarnapayment:selectpayment/>
Update the checkoutOrderSummary.tag
file to include:
<%@ taglib prefix="klarnacheckout" tagdir="/WEB-INF/tags/addons/klarnapaymentaddon/responsive/checkout" %>
<klarnacheckout:paymentInfo cartData="${cartData}" paymentInfo="${cartData.paymentInfo}" showPaymentInfo="${showPaymentInfo}" />
If using a customized paymentInfo.tag
, include hidden parameters from the add-on.
Include the following in kpBillingAddressFormElements.tag
:
<div class="form-element-icon datepicker date_of_birth" id="js-dateofbirth" data-date-format-for-date-picker="${dateFormatForDatePicker}">
<formElement:formInputBox idKey="dateOfBirth" labelKey="address.dateOfBirth" inputCSS="text" mandatory="false" path="dateOfBirth" placeholder="${dateFormatHint}"/>
<i class="glyphicon glyphicon-calendar js-open-datepicker-quote-expiration-time"></i>
</div>
acc.klarnapayment.js
to match the form name on your page. Example:checkPaymentSelected: function () {
klarnaData = {};
$("form input:radio[name='paymentMethod']").click(function () {
var paymentMethod = $('input[type=radio][name=paymentMethod]:checked').val();
if (paymentMethod == 'card') {
$('.submit_silentOrderPostForm').bind('click');
$('#klarna_container').empty();
$('#klarna_billing').hide();
$('#silentOrderPostForm').show();
ACC.silentorderpost.bindSubmitSilentOrderPostForm();
Example form name in silentOrderPostPage.jsp
:
<form:form id="silentOrderPostForm" name="silentOrderPostForm" commandName="sopPaymentDetailsForm" action="${paymentFormUrl}" method="POST">
bindPaymentsubmit: function () {
$('.submit_silentOrderPostForm').click(function () {
// your logic here
});
}
Modify the constant in KlarnaPaymentActiveFilter
:
public final static String DEFAULT_CHECKOUT_URL = "/checkout/multi/summary/placeOrder";
For B2B implementations using b2bacceleratoraddon, modify the paymentTypeForm.tag file to display Klarna Payment Type by replacing:
<form:radiobutton path="paymentType" id="PaymentTypeSelection_${paymentType.code}" value="${paymentType.code}" label="${paymentType.displayName}" />
With:
<c:choose>
<c:when test="${(paymentType.code eq 'CARD') && ('TRUE' eq isKlarnaActive)}">
<form:radiobutton path="paymentType" id="PaymentTypeSelection_${paymentType.code}" value="${paymentType.code}" label="Card payment or Klarna Pay" />
</c:when>
<c:otherwise>
<form:radiobutton path="paymentType" id="PaymentTypeSelection_${paymentType.code}" value="${paymentType.code}" label="${paymentType.displayName}" />
</c:otherwise>
</c:choose>
1. Rebuild the system: Navigate to <HYBRIS_HOME>/bin/platform
and run: ant clean all
2. Update the system:
JUnit test classes are located in the testsrc
folder of both the klarnapayment
and klarnapayment
extensions. Mock test classes for all supported Klarna API calls are available in the klarnapaymentapi
extension.
The KlarnaClientConnectionTest
integration test class is implemented in the klarnapaymentapi
extension. This class is used to test the connection to the Klarna server after initial tests.
Steps:
KlarnaClientConnectionTest
class with valid merchant test (playground) credentials. This helps identify any issues with authentication or payment session creation during server startup.Klarna Integration Connection Test Successful
. This confirms that SAP Commerce has successfully connected to Klarna.If the server is running, stop it using one of the following methods:
hybrisserver.bat stop
./hybrisserver.sh stop
Refer to the Installation section for additional details if needed.
Navigate to <HYBRIS_HOME>/bin/platform
and run the appropriate environment setup script:
setantenv.bat
./setantenv.sh
Note: This step is necessary only if the environment setup has not already been applied in the current terminal session.
Run the following command in <HYBRIS_HOME>/bin/platform
to remove the add-on:
<HYBRIS_HOME>/config/localextensions.xml
.<extension name="klarnapaymentaddon" />
<extension name="klarnapayment" />
<extension name="klarnapaymentapi" />
<extension name="klarnapaymentbackoffice" />
Remove the corresponding extension folders from <HYBRIS_HOME>/bin/custom
:
klarnapaymentaddon
klarnapayment
klarnapaymentapi
klarnapaymentbackoffice
<%@ taglib prefix="klarnapayment" tagdir="/WEB-INF/tags/addons/klarnapaymentaddon/responsive/" %>
<klarnapayment:selectpayment/>
ant clean build
HAC → Platform → Update
.----
Ensure the Klarna configuration is correctly set up for the current base store:
Conflicts with ItemType
definitions may occur in the latest versions of SAP Commerce (2005 and 2011), particularly based on the installation recipe.
It is advised to review and adjust the ItemType definitions to resolve any conflicts.
Market | Country Code | Region |
Australia | AU | OC |
Austria | AT | EU |
Belgium | BE | EU |
Canada | CA | NA |
Czech Republic | CZ | EU |
Denmark | DK | EU |
Finland | FI | EU |
France | FR | EU |
Germany | DE | EU |
Greece | GR | EU |
Hungary | HU | EU |
Ireland | IE | EU |
Italy | IT | EU |
Mexico | MX | NA |
Netherlands | NL | EU |
New Zealand | NZ | OC |
Norway | NO | EU |
Poland | PL | EU |
Portugal | PT | EU |
Romania | RO | EU |
Slovakia | SK | EU |
Spain | ES | EU |
Sweden | SE | EU |
Switzerland | CH | EU |
United Kingdom | GB | EU |
United States | US | NA |
SAP Commerce sends an order confirmation email to customers once an order is placed. However, since Klarna handles payment instructions and notifications directly with the customer, it is recommended to customize the Payment Details section of the confirmation email to clarify the following points:
Additionally, you can configure the payment method to display as "Purchased with Klarna" in the order confirmation email. To achieve this, follow these steps:
/klarnapaymentaddon/resources/klarnapaymentaddon/messages
Using Backoffice: