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: In addition to the encryption, you also need to format the input into hexadecimal format before you do the 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
Note: This call only works with KPM - do not use for Klarna Checkout. 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
Variable | Type | Description |
---|---|---|
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
Variable | Type | Description |
---|---|---|
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_invoice_due_date
The extend_invoice_due_date
call is used to extend the due date of invoices.
Note: Extending an invoice might incur a cost. To preview costs before extending invoice, use the calculate_only
boolean variable.
Call with the number of days to extend, and you get the cost and new end date in return.
Digest
Consist of the values from eid
, invno
and shared_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
- (int)
- Amount to be charged for extending the invoice
newDate
- New due date for the invoice
Call structure
Required | Variable | Type | Description | Comment |
---|---|---|---|---|
Required * | Variable proto_vsn | Type string | Description Use 4.1. | Comment Automatically set in the library. |
Required * | Variable client_vsn | Type string | Description xmlrpc:my-store-name:version-number. | Comment Automatically set in the library. |
Required * | Variable eid | Type int | Description Merchant ID. | Comment Identifies your store in Klarna’s database. |
Required * | Variable invno | Type string | Description Identifier for the invoice to extend. | Comment nan |
Required * | Variable digest | Type string | Description Digest for authentication. | Comment Klarna’s libraries do this for you together with the shared secret. |
Required * | Variable options | Type list | Description Contains settings. | Comment See below for more information. |
options
Item | Type | Description |
---|---|---|
Item days | Type int | Description Number of days to extend invoice by. |
Item calculate_only | Type boolean | Description Only calculate the cost - do not actually extend the invoice. |
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
<?xml version="1.0" encoding="ISO-8859-1"?> <methodCall> <methodName>extend_due_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> <!-- merchant id (eid) --> <int>0</int> </value> </param> <param> <value> <!-- invno --> <string>12345</string> </value> </param> <param> <value> <!-- shared_secret --> <string>replace_with_digest</string> </value> </param> <param> <value> <!-- extra info --> <struct> <member> <!-- days to extend --> <name>days</name> <value> <integer>7</integer> </value> </member> <member> <!-- only calculate --> <value> <boolean>1</boolean> </value> </member> </struct> </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
Variable | Type | Description |
---|---|---|
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>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
Variable | Type | Description |
---|---|---|
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 |
Variable | Type | Description |
---|---|---|
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 |
* Required
Variable | Type | Description |
---|---|---|
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. |
* Required † Required in Germany and Netherlands ‡ Required in Netherlands ❧ Required if cellno is not used ☙ Required if telno is not used
Variable | Type | Description |
---|---|---|
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 (deprecated)
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
Variable | Type | Description |
---|---|---|
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]
Call structure
* Required
Variable | Type | Description |
---|---|---|
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 |
Variable | Type | Description |
---|---|---|
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. |
Variable | Type | Description |
---|---|---|
Variable artno | Type string | Description Article number on item to be activated |
Variable qty | Type integer | Description Number of items to activate |
Variable | Type | Description |
---|---|---|
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. |
Variable | Type | Description |
---|---|---|
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 home_delivery registered_box unregistered_box pick_up_point own_delivery |
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 Germany</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 Germany</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
Variable | Type | Description |
---|---|---|
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
Variable | Type | Description |
---|---|---|
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
Variable | Type | Description |
---|---|---|
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. |
* Required
Variable | Type | Description |
---|---|---|
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
Variable | Type | Description |
---|---|---|
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
Variable | Type | Description |
---|---|---|
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>