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.

<?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
proto_vsn *stringUse 4.1. Automatically set in the library.
client_vsn *stringxmlrpc:my-store-name:version-number. Automatically set in the library.
eid *intA merchant ID which refers to your store in Klarna's database
digest *stringDigest for authentication. Klarna’s libraries do this for you together with the shared secret.
id *stringReservation number or order number, depending on the type variable
type *int
Determines which type of variable is to be used in "id".
 
0 = Reservation number
1 = Order number

Example

<?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
proto_vsn *stringUse 4.1. Automatically set in the library.
client_vsn *stringxmlrpc:my-store-name:version-number. Automatically set in the library.
rno *intReservation number of the reservation you want to cancel
eid *intA merchant ID which refers to your store in Klarna's database
digest *stringDigest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

<?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. 

Examplebase64encode(hex(sha512("[eid]:[rno]:[shared_secret]")))


Return value

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


Call structure

* Required

VariableTypeDescription
proto_vsn *stringUse 4.1. Automatically set in the library.
client_vsn *stringxmlrpc:my-store-name:version-number. Automatically set in the library.
rno *intReservation number of the reservation you want to extend
eid *intA merchant ID which refers to your store in Klarna's database
digest *stringDigest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

<?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
proto_vsn *stringUse 4.1. Automatically set in the library.
client_vsn *stringxmlrpc:my-store-name:version-number. Automatically set in the library.
eid *intA merchant ID which refers to your store in Klarna's database
digest *stringDigest for authentication. Klarna’s libraries do this for you together with the shared secret.
rno *stringThe reservation number of the reservation to be updated
update_info *struct
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
goods_liststructSee goods_list structure below for more information
dlv_addrstructSee address structure below for more information
bill_addrstructSee address structure below for more information
orderid1stringOrder ID #1
orderid2stringOrder ID #2

goods_list structure

* Required

VariableTypeDescription
qty *integerQuantity of the articles
artno *stringArticle number
title *stringArticle title
price *integer
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. 
vat *integer/floatVAT in percent
discountinteger/floatDiscount in percent
flagsinteger
8: Indicates that the item is a shipment fee
16: Indicates that the item is a handling fee
32: Send the prices including VAT
typestring

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
fname *stringConsumer's first name
lname *stringConsumer's last name
careofstringC/O address
companystringCompany name
street *stringStreet address
house_number †stringHouse number. Used in Germany and Netherlands. For all other countries you can send in an empty string.
house_extension ‡stringHouse extension. Only used in Netherlands, if the customer has one. For all other countries you can send in an empty string.
zip *stringZip Code
city *stringCity
country *integer
Code for the country where the consumer lives: 
 
15: Austria
59: Denmark
73: Finland
81: Germany
154: Netherlands
164: Norway
209: Sweden
telno ❧stringTelephone number
cellno ☙stringCellphone number
email *stringE-mail address

Example

<?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>
<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>
<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.

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
proto_vsn *stringUse 4.1. Automatically set in the library.
client_vsn *stringxmlrpc:my-store-name:version-number. Automatically set in the library.
rno *stringReservation number for the order to be split
split_amount *intThe amount to be subtracted from the reservation, given in cents, e.g. 10000 = 100 EUR.
orderid1stringOrder ID #1 for the new reservation
orderid2stringOrder ID #2 for the new reservation
flagsint
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.
eid *intA merchant ID which refers to your store in Klarna's database
digest *stringDigest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

<?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
proto_vsn *stringUse 4.1. Automatically set in the library.
client_vsn *stringxmlrpc:my-store-name:version-number. Automatically set in the library.
eid *intA merchant ID which refers to your store in Klarna's database
digest *stringDigest for authentication. Klarna’s libraries do this for you together with the shared secret.
rno *stringReservation number
optional_info*structSee optional_info structure below for more details

optional_info structure

VariableTypeDescription
orderid1stringOrder ID #1
orderid2stringOrder ID #2
flagsinteger
4: Send the invoice by mail
8: Send the invoice by e-mail
512: "Klarna Mobil" transaction
referencestringThe 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.
reference_codestringThe 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.
ocrstringThe payment reference number which the consumer will use to pay Klarna. Please ask for more information from your integration sales contact.
pinstringConsumer’s PIN code when using “Klarna Mobil” service
artnosstructUsed if you want to activate a part of an order. See Artnos structure below for more information.
shipping_infostructUsed to send information about shipment like tracking numbers. See shipment_info structure below for more information.

artnos structure

VariableTypeDescription
artnostringArticle number on item to be activated
qtyintegerNumber of items to activate

shipment_info structure

VariableTypeDescription
delay_adjustintegerThe 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
shipment_detailsarrayA list of shipment structures. See shipment structure below for more information.

shipment structure

VariableTypeDescription
tracking_numberstringTracking number for the outgoing parcel
tracking_urlstringURL to the shipping company's page for the outgoing parcel
shipping_companystringThe name of the shipping company for the outgoing parcel
shipping_methodstring

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

return_tracking_numberstringTracking number for the return parcel
return_tracking_urlstringURL to the shipping company's page for the return parcel
return_shipping_companystringThe name of the shipping company for the return parcel

Example

<?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>
<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>
<struct>
  <member>
    <name>qty</name>
    <value>
      <int>2</int>
    </value>
  </member>
  <member>
    <name>artno</name>
    <value>
      <string>1234</string>
    </value>
  </member>
</struct>
<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>
<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
proto_vsn *stringUse 4.1. Automatically set in the library.
client_vsn *stringxmlrpc:my-store-name:version-number. Automatically set in the library.
eid *intA merchant ID which refers to your store in Klarna's database
invno *stringInvoice number of the order you want to give discount to
amount *int
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.
vat *doubleVAT in percent
digest *stringDigest for authentication. Klarna’s libraries do this for you together with the shared secret.
flagsint32: Send price including VAT
titlestringTitle for the discount item

Example

<?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
proto_vsn *stringUse 4.1. Automatically set in the library.
client_vsn *stringxmlrpc:my-store-name:version-number. Automatically set in the library.
eid *intA merchant ID which refers to your store in Klarna's database
invno *stringInvoice-/OCR number of the invoice to be credited
crednostringCredit number to be used in the reconciliation report
digest *stringDigest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

<?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
proto_vsn *stringUse 4.1. Automatically set in the library.
client_vsn *stringxmlrpc:my-store-name:version-number. Automatically set in the library.
eid *intA merchant ID which refers to your store in Klarna's database
invno *stringInvoice-/OCR number of the invoice to be credited
artnos *listSee artnos structure below for more information
crednostringCredit number to be used in the reconciliation report
digest *stringDigest for authentication. Klarna’s libraries do this for you together with the shared secret.

Artnos structure

* Required

VariableTypeDescription
artno *stringArticle number on item to be returned
qty *intNumber of items to return

Example

<?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.

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
proto_vsn *stringUse 4.1. Automatically set in the library.
client_vsn *stringxmlrpc:my-store-name:version-number. Automatically set in the library.
eid *intA merchant ID which refers to your store in Klarna's database
invno *stringInvoice-/OCR number for the order to be sent by e-mail
digest *stringDigest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

<?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
proto_vsn *stringUse 4.1. Automatically set in the library.
client_vsn *stringxmlrpc:my-store-name:version-number. Automatically set in the library.
eid *intA merchant ID which refers to your store in Klarna's database
invno *stringInvoice-/OCR number for the order to be sent by postal mail
digest *stringDigest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

<?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
proto_vsn *stringUse 4.1. Automatically set in the library.
client_vsn *stringxmlrpc:my-store-name:version-number. Automatically set in the library.
eid *intA merchant ID which refers to your store in Klarna's database
invno *stringInvoice-/OCR number for the order to be sent by postal mail
digest *stringDigest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

<?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

<?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

<?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
proto_vsn *stringUse 4.1. Automatically set in the library.
client_vsn *stringxmlrpc:my-store-name:version-number. Automatically set in the library.
eid *intA merchant ID which refers to your store in Klarna's database
orderno *stringMerchant's order number 1
digest *stringDigest for authentication. Klarna’s libraries do this for you together with the shared secret.

Example

<?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

<?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
proto_vsn *stringUse 4.1. Automatically set in the library.
client_vsn *stringxmlrpc:my-store-name:version-number. Automatically set in the library.
eid *intA merchant ID which refers to your store in Klarna's database
invno *stringInvoice number you want to extend
digest *stringDigest for authentication. Klarna’s libraries do this for you together with the shared secret.
extra_info *listsee below for more information

 

Extra_info structure

VariableTypeDescription
daysintegerThe number of days to extend the invoice by
calculate_onlybooleanIf set to true, the return value will only calculate the cost, no extension will be triggered

Example

<?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

<?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>