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
- You have created an order
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:
1 2 3 4 5
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"))
1 2 3 4 5 6 7 8 9 10
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);
1 2 3 4 5 6 7 8
Klarna k = new Klarna( 0, "sharedSecret", KlarnaCountry.SE, KlarnaCurrency.SEK, new JsonStorage("/srv/data/pclasses.json"), Klarna.BETA );
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
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 );
1 2 3 4 5 6 7 8 9 10 11 12 13 14
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()
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:
1
Call kAPI.AddArticleNumber(1, "MG200MMS")
1
api.AddArticleNumber(2, "1234e");
1
k.addArtNo(2, "1234e");
1
$k->addArtNo(1, 'MG200MMS');
1
k.add_art_no(1, 'MG200MMS')
3. Include shipping information
If you are shipping physical goods you should have tracking information available at this point. The activation call therefore provides the possibility to transmit the tracking data for the shipment to Klarna. We may use this information to query the tracking information from the courier and inform the user about the status. We may even use this information internally to drive calls to your customer support down. Please provide the shipping company’s name as specifically as possible. e.g: “DHL Germany” instead of “DHL” or “TNT UK” instead of “TNT”. If you provide the customer with a return label in the package, please provide this return tracking number as well as part of this call. For more details about the shipment_info structure, click here .
4. Make the API call
Please initiate the API call to Klarna:
1 2
Dim result result = kAPI.Activate("123456", Null, RSRV_SEND_BY_EMAIL, True)
1 2 3 4 5
ActivateReservationResponse response = api.Activate( "123456", string.Empty, // OCR Number ReservationFlags.SendByEmail // Flags );
1 2 3 4 5
String[] result = k.activate( "123456789", "", // OCR Number EnumSet.of(Reservation.SEND_BY_EMAIL) );
1 2 3 4 5
$result = $k->activate( "987654321", null, // OCR Number KlarnaFlags::RSRV_SEND_BY_EMAIL );
1
(risk_status, invoice_number) = k.activate("123456789", flags=Reserve.SEND_BY_EMAIL)
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: 5. 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 resource while supplying a custom authentication header:
https://online.klarna.com/invoices/[invoice number].pdf
The authentication header is the following:
1
Authorization: KlarnaPdf [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 base64 encoded, as the following pseudo code suggests:
1
digest_secret = base64encode(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.
Optional step: 6. Access Packslip(s)
If needed, you may access the following resource while supplying a custom authentication header:
https://online.klarna.com/packslips/[packslip number].pdf
1
Authorization: KlarnaPdf [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 base64 encoded, as the following pseudo code suggests:
1
digest_secret = base64encode(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.