This product, Klarna Payments (kpm) is deprecated. Go to the current version

Introduction

Klarna offers an XML-RPC API to handle all orders which you can integrate with your back-office system in order to simplify your order management flows.

Using this API you can cancel , activate , update and refund orders.

Environment information

To test Klarna’s services, you need to apply for API credentials for the test environment. The test environment is exactly the same as Klarna’s live system, except no real invoices will be created and no credit checks are made.

To connect to the test environment, you need to change the host and port in the Klarna client libraries .

Host: payment.testdrive.klarna.com Port: 443

Digest

A digest is a cryptographic hash function that takes a block of data and returns a fixed-size bit string. The digest is used to verify the integrity of the call as well as to identify the caller, and sent in as a base64 encoded string.

Note: The string is formatted to hexadecimal before encoding.

Supported hashing algorithms are, in descending order of recommendation:

  • SHA-512
  • SHA-384
  • SHA-256
  • SHA-128
  • MD5 (deprecated)

The use of MD5 is strongly discouraged, and has been deprecated.

Error handling

When an error occurs, Klarna will respond with an error code and a message . The error message language is determined by the language code in the API call. If no language code can be used, Klarna will answer with the language of the consumer.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodResponse>
  <fault>
    <value>
      <struct>
        <member>
          <name>faultCode</name>
          <value>
            <int>8114</int>
          </value>
        </member>
        <member>
          <name>faultString</name>
          <value>
            <string>A problem ...</string>
          </value>
        </member>
      </struct>
    </value>
  </fault>
</methodResponse>

Methods

check_order_status

To check a reservation (order) status if it is ok, pending or denied.

Digest

Consist of the values from eid, id and secret (in this order) separated with a colon without the square brackets.

Example: base64encode(hex(sha512("[eid]:[id]:[shared_secret]")))

Return value

Integer - 1,2 or 3.

1 = OK 2 = Pending 3 = Denied

Call structure

* Required

VariableTypeDescription
Variable
proto_vsn *
Type
string
Description
Use 4.1. Automatically set in the library.
Variable
client_vsn *
Type
string
Description
xmlrpc:my-store-name:version-number. Automatically set in the library.
Variable
eid *
Type
int
Description
A merchant ID which refers to your store in Klarna’s database
Variable
digest *
Type
string
Description
Digest for authentication. Klarna’s libraries do this for you together with the shared secret.
Variable
id *
Type
string
Description
Reservation number or order number, depending on the type variable
Variable
type *
Type
int
Description
Determines which type of variable is to be used in “id”.
0 = Reservation number
1 = Order number

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>check_order_status</methodName>
  <params>
    <param>
      <value>
        <!-- proto_vsn -->
        <string>4.1</string>
      </value>
    </param>
    <param>
      <value>
        <!-- client_vsn -->
        <string>xmlrpc:my-store-name:1.2.3</string> 
      </value>
    </param>
    <param>
      <value>
        <!-- merchant id (eid) -->
        <int>0</int>
      </value>
    </param>
    <param>
      <value>
        <!-- shared_secret -->
        <string>replace_with_digest</string>
      </value>
    </param>
    <param>
      <value>
        <!-- id -->
        <string>123456</string>
      </value>
    </param>
    <param>
      <value>
        <!-- type -->
        <int>0</int>
      </value>
    </param>
  </params>
</methodCall>

cancel_reservation

To cancel a reservation

Digest

Consist of the values from eid, rno and secret (in this order) separated with a colon without the square brackets.

Example: base64encode(hex(sha512("[eid]:[rno]:[shared_secret]")))

Return value

String - OK

Call structure

* Required

VariableTypeDescription
Variable
proto_vsn *
Type
string
Description
Use 4.1. Automatically set in the library.
Variable
client_vsn *
Type
string
Description
xmlrpc:my-store-name:version-number. Automatically set in the library.
Variable
rno *
Type
int
Description
Reservation number of the reservation you want to cancel
Variable
eid *
Type
int
Description
A merchant ID which refers to your store in Klarna’s database
Variable
digest *
Type
string
Description
Digest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>cancel_reservation</methodName>
  <params>
    <param>
      <value>
        <!-- proto_vsn -->
        <string>4.1</string>
      </value>
    </param>
    <param>
      <value>
        <!-- client_vsn -->
        <string>xmlrpc:my-store-name:1.2.3</string> 
      </value>
    </param>
    <param>
      <value>
        <!-- rno -->
        <string>123456</string>
      </value>
    </param>
    <param>
      <value>
        <!-- merchant id (eid) -->
        <int>0</int>
      </value>
    </param>
    <param>
      <value>
        <!-- shared_secret -->
        <string>replace_with_digest</string>
      </value>
    </param>
  </params>
</methodCall>

extend_expiry_date

This call can be used to extend a reservations expiry date. For this to work, the reservations needs to be expired. The extended duration will be depending on your estores country settings for reservation validity. The default is 7 days.

Digest

Consist of the values from eid, rno and secret (in this order) separated with a colon without the square brackets.

Example: base64encode(hex(sha512("[eid]:[rno]:[shared_secret]")))

Return value

String - A date string in the format of “YYYYMMDDThhmmss” for example, 20150529T100532.

Call structure

* Required

VariableTypeDescription
Variable
proto_vsn *
Type
string
Description
Use 4.1. Automatically set in the library.
Variable
client_vsn *
Type
string
Description
xmlrpc:my-store-name:version-number. Automatically set in the library.
Variable
rno *
Type
int
Description
Reservation number of the reservation you want to extend
Variable
eid *
Type
int
Description
A merchant ID which refers to your store in Klarna’s database
Variable
digest *
Type
string
Description
Digest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>extend_expiry_date</methodName>
  <params>
    <param>
      <value>
        <!-- proto_vsn -->
        <string>4.1</string>
      </value>
    </param>
    <param>
      <value>
        <!-- client_vsn -->
        <string>xmlrpc:my-store-name:1.2.3</string> 
      </value>
    </param>
    <param>
      <value>
        <!-- rno -->
        <string>123456</string>
      </value>
    </param>
    <param>
      <value>
        <!-- merchant id (eid) -->
        <int>0</int>
      </value>
    </param>
    <param>
      <value>
        <!-- shared_secret -->
        <string>replace_with_digest</string>
      </value>
    </param>
  </params>
</methodCall>

update

The update function is used to update a reservation. This is useful when a consumer might want to change their order. Please note that Klarna may in some cases deny an update request.

Digest

Consist of all values from the variables which you send in the call separated with a colon without the square brackets. If you are not sending a specific struct in update_info, remove that from the digest. Shared secret must be the last variable.

If goods list is specified, include artno and qty for each product. Use title if artno isn’t specified. If billing and/or delivery address is specified, specify the address fields that are set.

Example: base64encode(hex(sha512( “4:1:[client_vsn]:[eid]:[rno] (:[dlv_careof])(:[dlv_street])(:[dlv_zip])(:[dlv_city]) (:[dlv_country])(:[dlv_fname])(:[dlv_lname]) (:[bill_careof])(:[bill_street])(:[bill_zip])(:[bill_city]) (:[bill_country])(:[bill_fname])(:[bill_lname]) (:[artno|title]:[qty]) (:[orderid1])(:[orderid2]) :[shared_secret]”)))

Return value

String - OK

Call structure

* Required

VariableTypeDescription
Variable
proto_vsn *
Type
string
Description
Use 4.1. Automatically set in the library.
Variable
client_vsn *
Type
string
Description
xmlrpc:my-store-name:version-number. Automatically set in the library.
Variable
eid *
Type
int
Description
A merchant ID which refers to your store in Klarna’s database
Variable
digest *
Type
string
Description
Digest for authentication. Klarna’s libraries do this for you together with the shared secret.
Variable
rno *
Type
string
Description
The reservation number of the reservation to be updated
Variable
update_info *
Type
struct
Description
The information you want to update. If you want to update an address, both addresses must be updated. The information you do not want to update, can be left empty. See update_info structure below for more information

update_info structure

VariableTypeDescription
Variable
goods_list
Type
struct
Description
See goods_list structure below for more information
Variable
dlv_addr
Type
struct
Description
See address structure below for more information
Variable
bill_addr
Type
struct
Description
See address structure below for more information
Variable
orderid1
Type
string
Description
Order ID #1
Variable
orderid2
Type
string
Description
Order ID #2

goods_list structure

* Required

VariableTypeDescription
Variable
qty *
Type
integer
Description
Quantity of the articles
Variable
artno *
Type
string
Description
Article number
Variable
title *
Type
string
Description
Article title
Variable
price *
Type
integer
Description
Article price, excluding VAT, given in cents, e.g. 10000 = 100 EUR. We always recommend to send in the price incl VAT by using the flag 32.
Variable
vat *
Type
integer/float
Description
VAT in percent
Variable
discount
Type
integer/float
Description
Discount in percent
Variable
flags
Type
integer
Description
8: Indicates that the item is a shipment fee
16: Indicates that the item is a handling fee
32: Send the prices including VAT
Variable
type
Type
string
Description
Optional variable. May be used to control the placement of this update on the consumer invoice. Can be one of the following: goods shipment handling discount By setting type to “discount” and VAT to 0, this item will be placed at the sub-total level of the invoice instead of in the line item list. If type is not set, it will default to goods in Klarna’s systems and thereby be placed as usual in the line item list on the invoice.

address structure

* Required † Required in Germany and Netherlands ‡ Required in Netherlands ❧ Required if cellno is not used ☙ Required if telno is not used

VariableTypeDescription
Variable
fname *
Type
string
Description
Consumer’s first name
Variable
lname *
Type
string
Description
Consumer’s last name
Variable
careof
Type
string
Description
C/O address
Variable
company
Type
string
Description
Company name
Variable
street *
Type
string
Description
Street address
Variable
house_number †
Type
string
Description
House number. Used in Germany and Netherlands. For all other countries you can send in an empty string.
Variable
house_extension ‡
Type
string
Description
House extension. Only used in Netherlands, if the customer has one. For all other countries you can send in an empty string.
Variable
zip *
Type
string
Description
Zip Code
Variable
city *
Type
string
Description
City
Variable
country *
Type
integer
Description
Code for the country where the consumer lives:
15: Austria
59: Denmark
73: Finland
81: Germany
154: Netherlands
164: Norway
209: Sweden
Variable
telno ❧
Type
string
Description
Telephone number
Variable
cellno ☙
Type
string
Description
Cellphone number
Variable
email *
Type
string
Description
E-mail address

Example

Update methodCall

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>update</methodName>
  <params>
    <param>
      <value>
        <!-- proto_vsn -->
        <string>4.1</string>
      </value>
    </param>
    <param>
      <value>
        <!-- client_vsn -->
        <string>xmlrpc:my-store-name:1.2.3</string> 
      </value>
    </param>
    <param>
      <value>
        <!-- merchant id (eid) -->
        <int>0</int>
      </value>
    </param>
    <param>
      <value>
        <!-- shared_secret -->
        <string>replace_with_digest</string>
      </value>
    </param>
    <param>
      <value>
        <!-- rno -->
        <string>123456</string>
      </value>
    </param>
    <param>
      <value>
        <!-- update_info -->
        <struct>
          <member>
            <name>goods_list</name>
            <value>
              <array>
                <data>
                  <value>
                    <!-- item struct -->
                  </value>
                </data>
              </array>
            </value>
          </member>
          <member>
            <name>dlv_addr</name>
            <value>
              <!-- address struct -->
            </value>
          </member>
          <member>
            <name>bill_addr</name>
            <value>
              <!-- address struct -->
            </value>
          </member>
          <member>
            <name>orderid1</name>
            <value>
              <string>12345</string>
            </value>
          </member>
          <member>
            <name>orderid2</name>
            <value>
              <string>6789</string>
            </value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodCall>

Item struct

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<struct>
  <member>
    <name>goods</name>
    <value>
      <struct>
        <member>
          <name>artno</name>
          <value>
            <string>MG200MMS</string>
          </value>
        </member>
        <member>
          <name>title</name>
          <value>
            <string>Matrox G200 MMS</string>
          </value>
        </member>
        <member>
          <name>price</name>
          <value>
            <int>29999</int>
          </value>
        </member>
        <member>
          <name>vat</name>
          <value>
            <double>25</double>
          </value>
        </member>
        <member>
          <name>discount</name>
          <value>
            <double>0</double>
          </value>
        </member>
        <member>
          <name>flags</name>
          <value>
            <int>32</int>
          </value>
        </member>
      </struct>
    </value>
  </member>
  <member>
    <name>qty</name>
    <value>
      <int>2</int>
    </value>
  </member>
</struct>

Address struct

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<struct>
  <member>
    <name>fname</name>
    <value>
      <string>Testperson-se</string>
    </value>
  </member>
  <member>
    <name>lname</name>
    <value>
      <string>Approved</string>
    </value>
  </member>
  <member>
    <name>careof</name>
    <value>
      <string>C/O last name</string>
    </value>
  </member>
  <member>
    <name>company</name>
    <value>
      <string>Test company</string>
    </value>
  </member>
  <member>
    <name>street</name>
    <value>
      <string>Stårgatan 1</string>
    </value>
  </member>
  <member>
    <name>house_number</name>
    <value>
      <string></string>
    </value>
  </member>
  <member>
    <name>house_extension</name>
    <value>
      <string></string>
    </value>
  </member>
  <member>
    <name>zip</name>
    <value>
      <string>12345</string>
    </value>
  </member>
  <member>
    <name>city</name>
    <value>
      <string>Ankeborg</string>
    </value>
  </member>
  <member>
    <name>country</name>
    <value>
      <int>209</int>
    </value>
  </member>
  <member>
    <name>telno</name>
    <value>
      <string></string>
    </value>
  </member>
  <member>
    <name>cellno</name>
    <value>
      <string>0765260000</string>
    </value>
  </member>
  <member>
    <name>email</name>
    <value>
      <string>testperson-se@example.com</string>
    </value>
  </member>
</struct>

split_reservation

The split_reservation function is used to split a reservation due to for example outstanding articles.

Please note: split_reservation function does not work with Klarna Checkout reservations.

Digest

Consist of the values from eid, rno, split_amount and secret (in this order) separated with a colon without the square brackets.

Example: base64encode(hex(sha512("[eid]:[rno]:[split_amount]:[shared_secret]")))

Return value

Array - [rno, orderStatus]

The value of “rno” is the reservation number for the new reservation. The value of “orderStatus” shows if the reservation can be delivered immediately or requires manual approval. If you receive “Pending”, you can use check_order_status to query Klarna for a new status.

1 = OK 2 = Pending

Call structure

* Required

VariableTypeDescription
Variable
proto_vsn *
Type
string
Description
Use 4.1. Automatically set in the library.
Variable
client_vsn *
Type
string
Description
xmlrpc:my-store-name:version-number. Automatically set in the library.
Variable
rno *
Type
string
Description
Reservation number for the order to be split
Variable
split_amount *
Type
int
Description
The amount to be subtracted from the reservation, given in cents, e.g. 10000 = 100 EUR.
Variable
orderid1
Type
string
Description
Order ID #1 for the new reservation
Variable
orderid2
Type
string
Description
Order ID #2 for the new reservation
Variable
flags
Type
int
Description
Flag which affects the invoiced purchase. Input 0 to set no flag. 2: If you set this flag, a test reservation is created despite your store working in live mode. It comes in handy if you wish to test something while avoiding any disturbance to your regular invoicing.
Variable
eid *
Type
int
Description
A merchant ID which refers to your store in Klarna’s database
Variable
digest *
Type
string
Description
Digest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>split_reservation</methodName>
  <params>
    <param>
      <value>
        <!-- proto_vsn -->
        <string>4.1</string>
      </value>
    </param>
    <param>
      <value>
        <!-- client_vsn -->
        <string>xmlrpc:my-store-name:1.2.3</string> 
      </value>
    </param>
    <param>
      <value>
        <!-- rno -->
        <string>123456</string>
      </value>
    </param>
    <param>
      <value>
        <!-- split_amount -->
        <int>10000</int>
      </value>
    </param>
    <param>
      <value>
        <!-- orderid1 -->
        <string>12345</string>
      </value>
    </param>
    <param>
      <value>
        <!-- orderid2 -->
        <string>6789</string>
      </value>
    </param>
    <param>
      <value>
        <!-- flags -->
        <int>0</int>
      </value>
    </param>
    <param>
      <value>
        <!-- merchant id (eid) -->
        <int>0</int>
      </value>
    </param>
    <param>
      <value>
        <!-- shared_secret -->
        <string>replace_with_digest</string>
      </value>
    </param>
  </params>
</methodCall>

activate

Activates a reservation matching the given reservation number.

Digest

Consist of all values from the variables which you send in the call separated with a colon without the square brackets. Variables in parentheses are optional.

If you are not sending a variable, remove that from the digest. Shared secret must be the last variable.

Example: base64encode(hex(sha512( “4:1:[client_vsn]:[eid]:[rno] :[flags](:[orderid1])(:[orderid2]) (:[referece])(:[reference_code]) :[shared_secret]”)))

Return value

Array - [risk_status,OCR number]

**Note:**If you have an Estore ID with delayed payment, the risk_status option can also return

  • no_risk - this response means that Klarna will not assume the fraud risk for this order

If you have a normal EID, no_risk will always return OK.

Call structure

* Required

VariableTypeDescription
Variable
proto_vsn *
Type
string
Description
Use 4.1. Automatically set in the library.
Variable
client_vsn *
Type
string
Description
xmlrpc:my-store-name:version-number. Automatically set in the library.
Variable
eid *
Type
int
Description
A merchant ID which refers to your store in Klarna’s database
Variable
digest *
Type
string
Description
Digest for authentication. Klarna’s libraries do this for you together with the shared secret.
Variable
rno *
Type
string
Description
Reservation number
Variable
optional_info*
Type
struct
Description
See optional_info structure below for more details

optional_info structure

VariableTypeDescription
Variable
orderid1
Type
string
Description
Order ID #1
Variable
orderid2
Type
string
Description
Order ID #2
Variable
flags
Type
integer
Description
4: Send the invoice by mail
8: Send the invoice by e-mail
512: “Klarna Mobil” transaction
Variable
reference
Type
string
Description
The reference person for the purchase if it is a company purchase. You can also use reference variable to write a message or other important information to the consumer on the invoice.
Variable
reference_code
Type
string
Description
The reference code for the sale. You can also use reference_code variable to write a message or other important information to the consumer on the invoice.
Variable
ocr
Type
string
Description
The payment reference number which the consumer will use to pay Klarna. Please ask for more information from your integration sales contact.
Variable
pin
Type
string
Description
Consumer’s PIN code when using “Klarna Mobil” service
Variable
artnos
Type
struct
Description
Used if you want to activate a part of an order. See Artnos structure below for more information.
Variable
shipping_info
Type
struct
Description
Used to send information about shipment like tracking numbers. See shipment_info structure below for more information.

artnos structure

VariableTypeDescription
Variable
artno
Type
string
Description
Article number on item to be activated
Variable
qty
Type
integer
Description
Number of items to activate

shipment_info structure

VariableTypeDescription
Variable
delay_adjust
Type
integer
Description
The two values determine how long after invoice activation Klarna starts countdown to the expiration date. Both countdowns are by default zero days. The time of the countdowns can be negotiated with Klarna.
1: Normal shipment
2: Express shipment
Variable
shipment_details
Type
array
Description
A list of shipment structures. See shipment structure below for more information.

shipment structure

VariableTypeDescription
Variable
tracking_number
Type
string
Description
Tracking number for the outgoing parcel
Variable
tracking_url
Type
string
Description
URL to the shipping company’s page for the outgoing parcel
Variable
shipping_company
Type
string
Description
The name of the shipping company for the outgoing parcel
Variable
shipping_method
Type
string
Description
Use one of the following options:
store_pick_up: An online purchase is picked up in the merchants own physical store.
home_delivery: Goods are sent home directly to customer’s home address via an external shipping company. This can either be a traceable or a non-traceable shipment.
registered_box: Goods are sent to a delivery box where the customer needs to be registered to pick them up. Example: DHL Packstation
unregistered_box: Goods are sent to a delivery box where the customer does not need to be registered to pick them up. Example: Itella smartpost, Hermes PaketShop
pick_up_point: Goods are sent to a manned pick-up point by an external shipping company. External personnel hands over goods to the customer.
own_delivery: Goods are sent home directly to customers home address via merchants own delivery service. Examples: Flower deliveries, food deliveries
Variable
return_tracking_number
Type
string
Description
Tracking number for the return parcel
Variable
return_tracking_url
Type
string
Description
URL to the shipping company’s page for the return parcel
Variable
return_shipping_company
Type
string
Description
The name of the shipping company for the return parcel

Example

Activate methodCall

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>activate</methodName>
  <params>
    <param>
      <value>
        <!-- proto_vsn -->
        <string>4.1</string>
      </value>
    </param>
    <param>
      <value>
        <!-- client_vsn -->
        <string>xmlrpc:my-store-name:1.2.3</string>
      </value>
    </param>
    <param>
      <value>
        <!-- merchant id (eid) -->
        <int>123456</int>
      </value>
    </param>
    <param>
      <value>
        <!-- shared_secret -->
        <string>replace_with_digest</string>
      </value>
    </param>
    <param>
      <value>
        <!-- rno -->
        <string>123456</string>
      </value>
    </param>
    <param>
      <value>
        <!-- optional_info struct -->
      </value>
    </param>
  </params>
</methodCall>

Optional info struct

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<struct>
  <member>
    <name>orderid1</name>
    <value>
      <string>12345</string>
    </value>
  </member>
  <member>
    <name>orderid2</name>
    <value>
      <string>6789</string>
    </value>
  </member>
  <member>
    <name>flags</name>
    <value>
      <int>8</int>
    </value>
  </member>
  <member>
    <name>reference</name>
    <value>
      <string>Testperson-se Approved</string>
    </value>
  </member>
  <member>
    <name>reference_code</name>
    <value>
      <string>Department 160</string>
    </value>
  </member>
  <member>
    <name>pin</name>
    <value>
      <string>1234</string>
    </value>
  </member>
  <member>
    <name>artnos</name>
    <value>
      <array>
        <data>
          <value>
            <!-- artno struct -->
          </value>
        </data>
      </array>
    </value>
  </member>
  <member>
    <name>shipment_info</name>
    <value>
      <!-- shipment_info struct -->
    </value>
  </member>
</struct>

Artno struct

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<struct>
  <member>
    <name>qty</name>
    <value>
      <int>2</int>
    </value>
  </member>
  <member>
    <name>artno</name>
    <value>
      <string>1234</string>
    </value>
  </member>
</struct>

Shipment details struct

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<struct>
  <member>
    <name>tracking_number</name>
    <value>
      <string>1234567890</string>
    </value>
  </member>
  <member>
    <name>tracking_uri</name>
    <value>
      <string>http://...</string>
    </value>
  </member>
  <member>
    <name>shipping_company</name>
    <value>
      <string>DHL</string>
    </value>
  </member>
  <member>
    <name>shipping_method</name>
    <value>
      <string>home_delivery</string>
    </value>
  </member>
  <member>
    <name>return_tracking_number</name>
    <value>
      <string>E-55-KL</string>
    </value>
  </member>
  <member>
    <name>return_tracking_uri</name>
    <value>
      <string>http://...</string>
    </value>
  </member>
  <member>
    <name>return_shipping_company</name>
    <value>
      <string>DHL</string>
    </value>
  </member>
</struct>

Shipment info struct

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<struct>
  <member>
    <name>delay_adjust</name>
    <value>
      <int>1</int>
    </value>
  </member>
  <member>
    <name>shipment_details</name>
    <value>
      <array>
        <data>
          <value>
            <!-- shipment_details struct -->
          </value>
        </data>
      </array>
    </value>
  </member>
</struct>

return_amount

The return_amount function is used to give discounts on invoices.

Digest

Consist of the values from eid, invno and secret (in this order) separated with a colon without the square brackets.

Example: base64encode(hex(sha512("[eid]:[invno]:[shared_secret]")))

Return value

String - OCR number for the discounted invoice

Call structure

* Required

VariableTypeDescription
Variable
proto_vsn *
Type
string
Description
Use 4.1. Automatically set in the library.
Variable
client_vsn *
Type
string
Description
xmlrpc:my-store-name:version-number. Automatically set in the library.
Variable
eid *
Type
int
Description
A merchant ID which refers to your store in Klarna’s database
Variable
invno *
Type
string
Description
Invoice number of the order you want to give discount to
Variable
amount *
Type
int
Description
Discount amount (excl. VAT), given in cents, e.g. 10000 = 100 EUR. We always recommend to send in the price incl VAT by using the flag 32.
Variable
vat *
Type
double
Description
VAT in percent
Variable
digest *
Type
string
Description
Digest for authentication. Klarna’s libraries do this for you together with the shared secret.
Variable
flags
Type
int
Description
32: Send price including VAT
Variable
title
Type
string
Description
Title for the discount item

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>return_amount</methodName>
  <params>
    <param>
      <value>
        <!-- proto_vsn -->
        <string>4.1</string>
      </value>
    </param>
    <param>
      <value>
        <!-- client_vsn -->
        <string>xmlrpc:my-store-name:1.2.3</string> 
      </value>
    </param>
    <param>
      <value>
        <!-- merchant id (eid) -->
        <int>0</int>
      </value>
    </param>
    <param>
      <value>
        <!-- invno -->
        <string>123456</string>
      </value>
    </param>
    <param>
      <value>
        <!-- amount -->
        <int>1000</int>
      </value>
    </param>
    <param>
      <value>
        <!-- vat -->
        <double>25</double>
      </value>
    </param>
    <param>
      <value>
        <!-- shared_secret -->
        <string>replace_with_digest</string>
      </value>
    </param>
    <param>
      <value><!-- flags -->
        <int>32</int>
      </value>
    </param>
    <param>
      <value>
        <!-- title -->
        <string>Discount fee</string>
      </value>
    </param>
  </params>
</methodCall>

credit_invoice

credit_invoice is used to make a complete refund on an order.

Digest

Consist of the values from eid, invno and secret (in this order) separated with a colon without the square brackets.

Example: base64encode(hex(sha512("[eid]:[invno]:[shared_secret]")))

Return value

String - OCR number for the returned invoice

Call structure

* Required

VariableTypeDescription
Variable
proto_vsn *
Type
string
Description
Use 4.1. Automatically set in the library.
Variable
client_vsn *
Type
string
Description
xmlrpc:my-store-name:version-number. Automatically set in the library.
Variable
eid *
Type
int
Description
A merchant ID which refers to your store in Klarna’s database
Variable
invno *
Type
string
Description
Invoice-/OCR number of the invoice to be credited
Variable
credno
Type
string
Description
Credit number to be used in the reconciliation report
Variable
digest *
Type
string
Description
Digest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>credit_invoice</methodName>
  <params>
    <param>
      <value>
        <!-- proto_vsn -->
        <string>4.1</string>
      </value>
    </param>
    <param>
      <value>
        <!-- client_vsn -->
        <string>xmlrpc:my-store-name:1.2.3</string> 
      </value>
    </param>
    <param>
      <value>
        <!-- merchant id (eid) -->
        <int>0</int>
      </value>
    </param>
    <param>
      <value>
        <!-- invno -->
        <string>123456</string>
      </value>
    </param>
    <param>
      <value>
        <!-- credno -->
        <string>6789</string>
      </value>
    </param>
    <param>
      <value>
        <!-- shared_secret -->
        <string>replace_with_digest</string>
      </value>
    </param>
  </params>
</methodCall>

credit_part

credit_part is used to make a partial refund on an order using the article numbers.

Digest

Consist of the values from eid, invno, artno, qty and secret (in this order) separated with a colon without the square brackets. Include the :[artno]:[qty] part of the digest for each product you want to credit.

Example: base64encode(hex(sha512("[eid]:[invno]:[artno]:[qty]:[shared_secret]")))

Return value

String - OCR number for the partly returned invoice

Call structure

* Required

VariableTypeDescription
Variable
proto_vsn *
Type
string
Description
Use 4.1. Automatically set in the library.
Variable
client_vsn *
Type
string
Description
xmlrpc:my-store-name:version-number. Automatically set in the library.
Variable
eid *
Type
int
Description
A merchant ID which refers to your store in Klarna’s database
Variable
invno *
Type
string
Description
Invoice-/OCR number of the invoice to be credited
Variable
artnos *
Type
list
Description
See artnos structure below for more information
Variable
credno
Type
string
Description
Credit number to be used in the reconciliation report
Variable
digest *
Type
string
Description
Digest for authentication. Klarna’s libraries do this for you together with the shared secret.

Artnos structure

* Required

VariableTypeDescription
Variable
artno *
Type
string
Description
Article number on item to be returned
Variable
qty *
Type
int
Description
Number of items to return

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>credit_part</methodName>
  <params>
    <param>
      <value>
        <array>
          <data>
            <value>
              <!-- proto_vsn -->
              <string>4.1</string>
            </value>
            <value>
              <!-- client_vsn -->
              <string>xmlrpc:my-store-name:1.2.3</string> 
            </value>
            <value>
              <!-- merchant id (eid) -->
              <int>0</int>
            </value>
            <value>
              <string></string>
            </value>
            <value>
              <array>
                <data>
                  <value>
                    <!-- artnos -->
                    <struct>
                      <member>
                        <name>artno</name>
                        <value>
                          <string>MG200MMS</string>
                        </value>
                      </member>
                      <member>
                        <name>qty</name>
                        <value>
                          <int>1</int>
                        </value>
                      </member>
                    </struct>
                  </value>
                </data>
              </array>
            </value>
            <value>
              <!-- credno -->
              <string>6789</string>
            </value>
            <value>
              <!-- shared_secret -->
              <string>replace_with_digest</string>
            </value>
          </data>
        </array>
      </value>
    </param>
  </params>
</methodCall>

email_invoice

The email_invoice function sends an invoice to the consumer via e-mail from Klarna. The email is sent in plain html format and contains a link to a PDF-invoice.

Please note: Regular postal service is used if the consumer has not entered any e-mail address when making the purchase (charges may apply).

Digest

Consist of the values from eid, invno and secret (in this order) separated with a colon without the square brackets.

Example: base64encode(hex(sha512("[eid]:[invno]:[shared_secret]")))

Return amount

String - OCR number for the e-mailed invoice

Call structure

* Required

VariableTypeDescription
Variable
proto_vsn *
Type
string
Description
Use 4.1. Automatically set in the library.
Variable
client_vsn *
Type
string
Description
xmlrpc:my-store-name:version-number. Automatically set in the library.
Variable
eid *
Type
int
Description
A merchant ID which refers to your store in Klarna’s database
Variable
invno *
Type
string
Description
Invoice-/OCR number for the order to be sent by e-mail
Variable
digest *
Type
string
Description
Digest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>email_invoice</methodName>
  <params>
    <param>
      <value>
        <!-- proto_vsn -->
        <string>4.1</string>
      </value>
    </param>
    <param>
      <value>
        <!-- client_vsn -->
        <string>xmlrpc:my-store-name:1.2.3</string> 
      </value>
    </param>
    <param>
      <value>
        <!-- merchant id (eid) -->
        <int>0</int>
      </value>
    </param>
    <param>
      <value>
        <!-- invno -->
        <string>123456</string>
      </value>
    </param>
    <param>
      <value>
        <!-- shared_secret -->
        <string>replace_with_digest</string>
      </value>
    </param>
  </params>
</methodCall>

send_invoice

The send_invoice function is used to request a postal send-out of an activated invoice to a consumer by Klarna (charges may apply).

Digest

Consist of the values from eid, invno and secret (in this order) separated with a colon without the square brackets.

Example: base64encode(hex(sha512("[eid]:[invno]:[shared_secret]")))

Return value

String - OCR number for the mailed invoice

Call structure

* Required

VariableTypeDescription
Variable
proto_vsn *
Type
string
Description
Use 4.1. Automatically set in the library.
Variable
client_vsn *
Type
string
Description
xmlrpc:my-store-name:version-number. Automatically set in the library.
Variable
eid *
Type
int
Description
A merchant ID which refers to your store in Klarna’s database
Variable
invno *
Type
string
Description
Invoice-/OCR number for the order to be sent by postal mail
Variable
digest *
Type
string
Description
Digest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>send_invoice</methodName>
  <params>
    <param>
      <value>
        <!-- proto_vsn -->
        <string>4.1</string>
      </value>
    </param>
    <param>
      <value>
        <!-- client_vsn -->
        <string>xmlrpc:my-store-name:1.2.3</string> 
      </value>
    </param>
    <param>
      <value>
        <!-- merchant id (eid) -->
        <int>0</int>
      </value>
    </param>
    <param>
      <value>
        <!-- invno -->
        <string>123456</string>
      </value>
    </param>
    <param>
      <value>
        <!-- shared_secret -->
        <string>replace_with_digest</string>
      </value>
    </param>
  </params>
</methodCall>

order_info

To get information of an order

Digest

Consist of the values from eid, invno and secret (in this order) separated with a colon without the square brackets.

Example: base64encode(hex(sha512("[eid]:[invno]:[shared_secret]")))

Return value

Array - [payMethod, isPaid, dueDate]

payMethod - invoice, card etc

isPaid - “Yes” or “Contact Klarna”

dueDate - “-” or date in format of “2016-12-31”

Call structure

* Required

VariableTypeDescription
Variable
proto_vsn *
Type
string
Description
Use 4.1. Automatically set in the library.
Variable
client_vsn *
Type
string
Description
xmlrpc:my-store-name:version-number. Automatically set in the library.
Variable
eid *
Type
int
Description
A merchant ID which refers to your store in Klarna’s database
Variable
invno *
Type
string
Description
Invoice-/OCR number for the order to be sent by postal mail
Variable
digest *
Type
string
Description
Digest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>order_info</methodName>
  <params>
    <param>
      <!-- API version -->
      <value>
        <string>4.2</string>
      </value>
    </param>
    <param>
      <!-- client version -->
      <value>
        <string>php:api:2.3.3</string>
      </value>
    </param>
    <param>
      <!-- eid -->
      <value>
        <int>2</int>
      </value>
    </param>
    <param>
      <!-- invno -->
      <value>
        <string>123456789012345</string>
      </value>
    </param>
    <param>
      <!-- shared secret digest -->
      <value>
        <string>base64ofsomedigest</string>
      </value>
    </param>
  </params>
</methodCall>

Example response: invoice is paid

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodResponse>
  <params>
    <param>
      <value>
        <array>
          <data>
            <!-- payment method -->
            <value>
              <string>invoice</string>
            </value>
            <!-- payment done -->
            <value>
              <string>Yes</string>
            </value>
            <!-- due date -->
            <value>
              <string>-</string>
            </value>
          </data>
        </array>
      </value>
    </param>
  </params>
</methodResponse>

Example response: invoice is not paid

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodResponse>
  <params>
    <param>
      <value>
        <array>
          <data>
            <!-- payment method -->
            <value>
              <string>invoice</string>
            </value>
            <!-- payment done -->
            <value>
              <string>Contact Klarna</string>
            </value>
            <!-- due date -->
            <value>
              <string>2016-12-31</string>
            </value>
          </data>
        </array>
      </value>
    </param>
  </params>
</methodResponse>

lookup_invoice

To lookup Klarna’s invoice number based on order number 1

Digest

Consist of the values from eid, orderno and secret (in this order) separated with a colon without the square brackets.

Example: base64encode(hex(sha512("[eid]:[orderno]:[shared_secret]")))

Return value

Array - [invno]

invno - Klarnas invoice number connected to the order number

Call structure

* Required

VariableTypeDescription
Variable
proto_vsn *
Type
string
Description
Use 4.1. Automatically set in the library.
Variable
client_vsn *
Type
string
Description
xmlrpc:my-store-name:version-number. Automatically set in the library.
Variable
eid *
Type
int
Description
A merchant ID which refers to your store in Klarna’s database
Variable
orderno *
Type
string
Description
Merchant’s order number 1
Variable
digest *
Type
string
Description
Digest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>lookup_invoice</methodName>
  <params>
    <param>
      <!-- API version -->
      <value>
        <string>4.2</string>
      </value>
    </param>
    <param>
      <!-- client version -->
      <value>
        <string>php:api:2.3.3</string>
      </value>
    </param>
    <param>
      <!-- eid -->
      <value>
        <int>2</int>
      </value>
    </param>
    <param>
      <!-- orderno -->
      <value>
        <string>order12345</string>
      </value>
    </param>
    <param>
      <!-- shared secret digest -->
      <value>
        <string>base64ofsomedigest</string>
      </value>
    </param>
  </params>
</methodCall>

Example response

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodResponse>
  <params>
    <param>
      <value>
        <array>
          <data>
            <!-- invoice numbers -->
            <value>
              <int>123456789012345</int>
            </value>
            <value>
              <int>234567890123456</int>
            </value>
          </data>
        </array>
      </value>
    </param>
  </params>
</methodResponse>

extend_invoice_due_date

extend_invoice_due_date is used to extend the due date of invoices. Note that extending an invoice might come with a cost. Use calculate_only variable to see eventual costs before extending invoice if required.

Digest

Consist of the values from eid, invno and secret (in this order) separated with a colon without the square brackets.

Example: base64encode(hex(sha512("[eid]:[invno]:[shared_secret]")))

Return value

Array - [cost,newDate]

cost - cost is the amount that will be charged to extend the invoice

newDate - newDate is the new due date the invoice gets

Call structure

* Required

VariableTypeDescription
Variable
proto_vsn *
Type
string
Description
Use 4.1. Automatically set in the library.
Variable
client_vsn *
Type
string
Description
xmlrpc:my-store-name:version-number. Automatically set in the library.
Variable
eid *
Type
int
Description
A merchant ID which refers to your store in Klarna’s database
Variable
invno *
Type
string
Description
Invoice number you want to extend
Variable
digest *
Type
string
Description
Digest for authentication. Klarna’s libraries do this for you together with the shared secret.
Variable
extra_info *
Type
list
Description
see below for more information

Extra_info structure

VariableTypeDescription
Variable
days
Type
integer
Description
The number of days to extend the invoice by
Variable
calculate_only
Type
boolean
Description
If set to true, the return value will only calculate the cost, no extension will be triggered

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
  <methodName>extend_invoice_due_date</methodName>
  <params>
    <param>
      <!-- API version -->
      <value>
        <string>4.2</string>
      </value>
    </param>
    <param>
      <!-- client version -->
      <value>
        <string>php:api:2.3.3</string>
      </value>
    </param>
    <param>
      <!-- eid -->
      <value>
        <int>2</int>
      </value>
    </param>
    <param>
      <!-- invno -->
      <value>
        <string>123456789012345</string>
      </value>
    </param>
    <param>
      <!-- shared secret digest -->
      <value>
        <string>base64ofsomedigest</string>
      </value>
    </param>
    <param>
      <value>
        <!-- variables -->
        <struct>
          <member>
            <!-- days to extend -->
            <name>days</name>
            <value>
              <integer>14</integer>
            </value>
          </member>
          <member>
            <name>calculate_only</name>
            <value>
              <boolean>1</boolean>
            </value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodCall>

Example response

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodResponse>
  <params>
    <param>
      <value>
        <struct>
          <member>
            <name>new_date</name>
            <value>
              <string>2015-12-31</string>
            </value>
          </member>
          <member>
            <name>cost</name>
            <value>
              <int>350</int>
            </value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodResponse>