Activate an order

This functionality activates the order. This call will inform Klarna that the order has been shipped. Klarna will then trigger your pay-out and send an invoice to the consumer.

Use case

The order has been prepared in your warehouse, and is ready to be dispatched. You ship the order and inform Klarna.

Prerequisities


1. Initialize the Klarna object

Each Klarna library function requires a basic setup of the Klarna object. This configuration specifies how the library communicates with Klarna’s servers.

Follow the code examples below to see how to do this with our different libraries:

use Klarna\XMLRPC\Klarna;
use Klarna\XMLRPC\Country;
use Klarna\XMLRPC\Language;
use Klarna\XMLRPC\Currency;

$k = new Klarna();

$k->config(
    0,              // Merchant ID
    'sharedSecret', // Shared secret
    Country::SE,    // Purchase country
    Language::SV,   // Purchase language
    Currency::SEK,  // Purchase currency
    Klarna::BETA,   // Server
);
Klarna k = new Klarna(
        0,
        "sharedSecret",
        KlarnaCountry.SE,
        KlarnaCurrency.SEK,
        new JsonStorage("/srv/data/pclasses.json"),
        Klarna.BETA
);
config = klarna.Config(
    eid=0,
    secret='sharedSecret',
    country='DE',
    language='DE',
    currency='EUR',
    mode='beta',
    pcstorage='json',
    pcuri='/srv/pclasses.json',
    scheme='https',
    candice=True)

k = klarna.Klarna(config)
k.init()
Configuration configuration = new Configuration(
    Country.Code.SE, Language.Code.SV, Currency.Code.SEK,
    Encoding.Sweden)
{
    Eid = 0,
    Secret = "sharedsecret",
    IsLiveMode = false
};

Api api = new Api(configuration);
Dim kAPI
Set kAPI = GetKlarna(0, "sharedsecret", "SE", "SV", "SEK")
kAPI.SetPort(HTTPS_PORT) ' or HTTP_PORT
kAPI.SetHost(BETA_HOST) ' or LIVE_HOST
kAPI.SetPClassesStorageUri(Server.MapPath("pclasses.xml"))

2. Add optional information

If you offer invoice and part payment, you may include optional information in the Activate call, such as a new internal order ID or an indication of how Klarna should send the invoice to the consumer.

In Klarna Checkout, the consumer makes this choice.

Partial activation

If you wish to partially activate an order, all you have to do is supply the article number and quantity of the items you wish to ship:

$k->addArtNo(1, 'MG200MMS');
k.addArtNo(2, "1234e");
k.add_art_no(1, 'MG200MMS')
api.AddArticleNumber(2, "1234e");
Call kAPI.AddArticleNumber(1, "MG200MMS")

3. Make the API call

Please initiate the API call to Klarna:

$result = $k->activate(
    "987654321", 
    null,    // OCR Number
    KlarnaFlags::RSRV_SEND_BY_EMAIL
);
String[] result = k.activate(
        "123456789",
        "",    // OCR Number
        EnumSet.of(Reservation.SEND_BY_EMAIL)
);
(risk_status, invoice_number) = k.activate("123456789", flags=Reserve.SEND_BY_EMAIL)
ActivateReservationResponse response = api.Activate(
    "123456",
    string.Empty,                // OCR Number
    ReservationFlags.SendByEmail // Flags
);
Dim result
result = kAPI.Activate("123456", Null, RSRV_SEND_BY_EMAIL, True)

Klarna will respond with an array, containing two variables:

risk_status - This represents the risk status:

  • OK - this response means that the order has passed Klarna’s fraud and credit assessment

invoice number

  • This number represents the invoice number in Klarna’s system and should be used in all subsequent order handling calls.

 

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.


Optional step: 4. Access the invoice

If needed, you may retrieve the invoice as a PDF file by either logging in to Klarna Online (merchants.klarna.com) and looking up the invoice there, or accessing the following secure link:

  • https://online.klarna.com/invoices/[invoice number].pdf?secret=[URL encoded digest secret]

[URL encoded digest secret]: In order to authenticate towards this service to read this invoice, you need to generate a digest, similar to like you did when placing the order. The digest is a sha512 encryption of the values eid, invno and secret, in a colon separated string that is then hashed and base64 encoded, as the following pseudo code suggests:

digest_secret = base64encode(hash(sha512([eid]:[invno]:[secret])))

As a last step, in order for the browser to handle potential spaces and + signs, you need to URL encode the digest_secret before accessing the secure link above. If you need help with URL encoding, there are a number of resources available online to help you out for your particular programming language.