Prerequisites
Before you start, ensure:
The klarnapaymentaddon is successfully installed.
You have access to the SAP Commerce Backoffice.
Credentials from the Klarna Merchant Portal, including API username , API password , and Public Key ID .
Steps to Activate Klarna Payments
Step 1: Create a Klarna Payments configuration
1. Navigate to Klarna Payment Configuration: Go to SAP Commerce Backoffice → Klarna → Klarna Payments Config .
Navigate to Klarna Payment Configuration
2. Create a new Klarna configuration: Select the option to create a new Klarna configuration.
Create a New Klarna Configuration
3. Fill in mandatory fields:
Code: A unique identifier for the configuration.
Enable Klarna Payments: Toggle to enable the feature.
Email for Failure Notifications: Email for receiving alerts.
Click Next to proceed.
Fill in the Klarna Payments Specific Fields
4. Provide additional details:
Enable AutoCapture (optional).
Enable Extra Merchant Data (EMD) (optional).
Set Merchant Reference 2 and optional color customization for the Klarna interface.
Fill in the Klarna Payments Specific Fields 2
Step 2: Create credential data
1. Navigate to Klarna Activation: In the Backoffice, go to Klarna → Klarna Activation .
2. Add a new credential: Click the + icon below the Klarna Activation section.
3. Fill in mandatory fields:
Code: Identifier for the credentials.
Client ID, API Username, and API Password: Retrieved from the Klarna Merchant Portal.
4. Provide additional details:
Region (e.g., EUROPE, NORTH_AMERICA).
Supported Markets .
Enable VCN if applicable.
Public Key ID: For encrypting VCN data.
Credential additional details
Step 3: Map credentials and Klarna Payments configuration
1. Navigate to Klarna Common Configuration: Go to Klarna → Klarna Common Configuration .
2. Create a mapping:
Click the + icon to create a new mapping.
Fill in details such as Code , Active , and Environment (TEST or LIVE).
3. Link Klarna credentials and payment configuration:
Klarna Payments Configuration Fields
Attribute Mandatory Description Klarna API Username Yes Generated in Klarna Merchant Portal. Klarna API Password Yes Generated in Klarna Merchant Portal. Region Yes Choose from EUROPE, NORTH_AMERICA, or OCEANIA. Markets Yes Countries supported under the selected region. Environment Yes TEST (playground) or LIVE (production). AutoCapture No Enables auto capturing during order placement (not relevant if VCN is enabled). Enable VCN No Toggles VCN-based settlement. Public Key ID No RSA public key provided in JWK format for VCN settlement. Recommended: 4096-bit RSA keypair.
Tips for an Optimal User Experience
Ensure the Klarna Payments iframe is visible and text is legible by using a consistent minimum width for checkout and billing pages. This enhances the experience for mobile users.
Setting Up Virtual Card Numbers (VCN)
Steps to Enable VCN
Step 1: Enable VCN in Klarna Configuration
Access Klarna Activation:
Step 2: Generate a 4096-bit RSA Key Pair
1. Open a terminal and run the following commands:
1
2
3
openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:4096
openssl rsa -pubout -in private_key.pem -out public_key.pem
2. This will create two files:
In Klarna Activation , set the Public Key ID using the contents of public_key.pem.
Example public_key.pem file contents:
1
2
3
4
5
6
7
8
9
10
-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAoNYG7l2G8nZa+22oBYZk
tV228lw3UE9WO4oxfknJtKEdHn84x55ULt8KQTh9NVtdeKC8nTfTgyvMt/GNCa18
xuZV/lGYDftKt85hbV5EjOum+StAIufEXvlBX7nMOMc1KyWm9kp2kbqd88mFIX63
KV94OoNEXcNatRDFYR+qz53+ifadDQtQ1slVNStdroCZDJ1+LxtBy9V+BdmsBK1E
RLsKh/JLXyWE24FJKV+z00s7TQkdWW/5ET12OGQYZsWo1yqgi9HplNvrisve8vWP
xaL4m8iZ3I/9yYdg7yANQbTxSJcbbRCgaaagPo30CNxeqU6qafY5g8vY3E52CoXH
DdO4UslX1qcuYIDhqaDzey6W+b8m755xLi+rqQyM4PBWL0J0dM3FVid8+4YKILex
3AKBFciqRCMHSOGaEeyrXKTjlAsghr9RS8PifvQRrL440cHzqw2vX0DvpjSWcmUJ
tW4wUq5RNSsobrxnVmoV6fj1z67Q/1P+l5Ie+oowdahR5ztVqJlO+2PNoX4I5VDs
Expand
Important Notes on PCI Compliance
Do not save decrypted PCI data (e.g., VCN or CVV) on servers.
Ensure PCI-DSS compliance by securely handling card data.
Collaborate with partners, Payment Service Providers (PSP), and Acquirers for secure data management.
Delete any historical decrypted PCI data, regardless of its validity.
Verifying VCN Data in Backoffice
1. Access the Order
2. View Order Details
Important!
VCNs are one-time use cards tied to individual orders.
Merchants are responsible for securely managing the cards.
Avoid storing decrypted PCI data in production environments.
Verifying Klarna Order IDs in Backoffice
Steps to Verify Klarna Orders
Log in to SAP Commerce Backoffice.
Search for a Specific Order:
Viewing Klarna-Specific Details
1. Verify Klarna Order ID:
2. Check Payment Transactions:
Verify Payment Transactions
The Extra Merchant Data (EMD) feature allows merchants to send additional customer information to Klarna, such as alternative delivery addresses and reservation details. By default, only logged-in customer information is sent.
Steps to Enable EMD in SAP Commerce Backoffice
Navigate to the Backoffice:
Configuring EMD in Code
To extend the EMD functionality beyond the default behavior:
Open the KPCreditSessionPopulator.java File: Locate the file in your SAP Commerce extension codebase.
Use the addAttachment Method:
This method is exposed for configuring EMD data.
Replace yourDataObject with the required data (e.g., customer preferences or reservation details).
Example usage: addAttachment("additionalData", yourDataObject);
Compile and Deploy the Changes: Build your extension and deploy it to the SAP Commerce environment.
Best Practices for EMD and Order Verification
Use the addAttachment method to ensure relevant EMD fields are properly configured for Klarna Payments.
Regularly monitor orders in Backoffice to ensure accurate mappings between Klarna and SAP Commerce configurations.
Appendix
Extension Model and Classes
Model OOB Model Attributes BaseStore BaseStore klarnaPayConfig AbstractOrder AbstractOrder kpIdentifier kpAnonymousGUID kpOrderId kpFraudStatus isKpPendingOrder isKpAuthorised isKpFraudRiskStopped KPPaymentInfo InvoicePaymentInfo paymentOption finalizeRequired description authToken isVCNUsed vcnBrand vcnCSC vcnValidToYear vcnValidToMonth vcnHolder vcnPan vcnCVV
Class OOB Class KPPaymentMethodCheckoutStepController PaymentMethodCheckoutStepController KPSummaryCheckoutStepController AbstractCheckoutStepController KlarnaResponsiveSummaryCheckoutStepValidator AbstractCheckoutStepValidator KlarnaSummaryCheckoutStepValidator AbstractCheckoutStepValidator KPAddressPopulator AddressPopulator KPOrderPopulator AbstractOrderPopulator KlarnaEventPublishingSubmitOrderStrategy SubmitOrderStrategy KPPaymentTypeCheckoutStepController AbstractCheckoutStepController
Klarna Payment Method Reference
Use Case Class Method Create/Update payment session DefaultKPPaymentFacade getORcreateORUpdateSession Authorize Payment DefaultKPPaymentFacade getPaymentAuthorization Create Klarna Order DefaultKPPaymentCheckoutFacade saveKlarnaOrderId Cancel Klarna Order KPOrderConfirmationController orderConfirmation
KlarnapaymentAPI Method Reference
Use Case Class Method Get Klarna Payment session Client newPaymentsSessionsApi Authorize Payment Client newPaymentsOrdersApi Get Klarna Order by ID Client newOrderManagementOrdersApi Create payment Settlement Client newVirtualCreditCardSettlementsApi Delete Auth newPaymentsOrdersApi Capture Payment newOrderManagementCapturesApi