Closed (fixed)
Project:
Commerce Klarna Payments
Version:
3.0.0-beta3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Jan 2025 at 18:51 UTC
Updated:
19 Feb 2025 at 07:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
cruze72 commentedI have tested the latest version of the module beta-3.0.0 and get the following error message:
An error occurred for order #698: [Klarna\ApiException]: [401] Client error: `POST https://api.klarna.com/payments/v1/sessions` resulted in a `401 Unauthorized` response: @"error_code": "PERMISSION_DENIED", "error_message": "Authentication failed or permission not granted"
$form['password'] = [
'#type' => 'textfield',
'#title' => $this->t('Password'),
'#default_value' => $this->configuration['password'],
'#maxlength' => 255,
];
I added suggested fix but still get the error.
Comment #5
tuutti commentedCan you check if overriding the API key in settings.php works?
Add something like this to your settings.php file, just replace the
klarna_paymentswith the actual ID of your Klarna payment gateway:$config['commerce_payment.commerce_payment_gateway.klarna_payments']['configuration']['password'] = '123';You can check if the new value is set with drush:
drush cget commerce_payment.commerce_payment_gateway.klarna_payments --include-overriddenComment #6
cruze72 commentedHi,
Unfortunately not.
Error when processing a transaction:
An error occurred for order #709: [Klarna\ApiException]: [401] Client error: `POST https://api.klarna.com/payments/v1/sessions` resulted in a `401 Unauthorized` response: @"error_code": "PERMISSION_DENIED", "error_message": "Authentication failed or permission not granted"
Error when running drush command:
[error] Config commerce_payment.commerce_payment_gateway.klarna_payments does not exist
I have tested with password key in the following formats:
Comment #7
tuutti commentedYou need to change the
klarna_paymentspart to match whatever your payment gateway ID is.You can find it by going to Commerce -> Configuration -> Payment gateways.
It should be the value of "ID" field. In my case it's

klarna_payments:So if your ID were called
klarna_something, then the drush command should be:drush cget commerce_payment.commerce_payment_gateway.klarna_something --include-overriddenAnd the $config:
Comment #8
cruze72 commentedGot it. Here is the result:
uuid: f7d15d54-b589-4a9c-bfdf-55716c0716d7
langcode: en
status: true
dependencies:
module:
- commerce_klarna_payments
id: klarna
label: Klarna
weight: null
plugin: klarna_payments
configuration:
display_label: 'Klarna Payments'
mode: live
payment_method_types:
- 'Credit card'
collect_billing_information: true
username: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
password: bnlNIW8pL0NXUGw_TTJLKjY4akpqRXB0SVdmSmxrVU0sYzQyZDg0YzktYjYxMy00NzJlLThlYjYtYjM0ZmYwNDQ4Y2VhLDEsNWJIQTU2ajFBa3Ro
region: eu
cancel_fraudulent_orders: false
options:
color_border: ''
color_border_selected: ''
color_text: ''
color_details: ''
radius_border: ''
conditions: { }
conditionOperator: AND
I am correct in taking the client API keys as the username and password from the Klarna settings and not SMTP or client ID?
Comment #9
cruze72 commentedUpon further testing it appears the same error message is shown with the similar Commerce Klarna Checkout module.
"PERMISSION_DENIED", "error_message": "Authentication failed or permission not granted"
Would this indicate that either Klarna has changed their API or i am using the wrong login credentials.
Within the Klarna merchant portal there are three options for integrating:
1.Klarna API keys
2. Client ID with password
3. SMTP authentication
I've tried with all three variants and in the case of #1 - with and without the 'klarna_live_api_' prefix in the password.
I am assuming i should use #1 ...?
Comment #10
tuutti commentedGo to Settings -> Klarna API Keys -> click "Generate new Klarna API Key" button and it should give a downloadable text file with "username" and "password".
The password should include the
klarna_live_api_prefixComment #12
tuutti commented