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.
Prerequisites
- You have created (or acknowledged , if you’re using Klarna Checkout) 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 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()
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);
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
k.addArtNo(2, "1234e");
1
$k->addArtNo(1, 'MG200MMS');
1
k.add_art_no(1, 'MG200MMS')
1
Call kAPI.AddArticleNumber(1, "MG200MMS")
1
api.AddArticleNumber(2, "1234e");
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 .
If you are using one of our SDKs you can see some examples on how to send shipping information here:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
final HashMap<String, String> shipping = new HashMap<String, String>() { { put("tracking_number", "1234567890"); put("shipping_company", "Postnord"); // If you already know the tracking number of the return, you can transmit it: put("return_tracking_number", "SE1234567898XY"); put("return_shipping_company", "DHL Germany"); } }; ArrayList shipment_details = new ArrayList() { { add(shipping); } }; k.setAdditionalInformation(InformationType.SHIPMENT, "shipment_details", shipment_details);
1 2 3 4 5 6 7 8 9 10 11
$k = new Klarna(); $shipmentInfo = array(); $shipmentInfo['tracking_number'] = "1234567890"; $shipmentInfo['shipping_company'] = "Postnord"; // If you already know the tracking number of the return, you can transmit it: $shipmentInfo['return_tracking_number'] = "SE1234567898XY"; $shipmentInfo['return_shipping_company'] = "DHL Germany"; $k->setShipmentInfo("shipment_details", array($shipmentInfo));
1 2 3 4 5 6 7 8 9 10 11
shipping = { 'tracking_number': '1234567890', 'shipping_company': 'Postnord', # If you already know the tracking number of the return, you can transmit it: 'return_tracking_number': 'SE1234567898XY', 'return_shipping_company': 'DHL Germany' } shipment_details = [shipping] k.set_shipment_info(shipment_details=shipment_details)
1 2 3 4 5 6 7 8 9 10 11 12
CookComputing.XmlRpc.XmlRpcStruct shipping = new CookComputing.XmlRpc.XmlRpcStruct(); shipping.Add("tracking_number", "1234567890"); shipping.Add("shipping_company", "Postnord"); // If you already know the tracking number of the return, you can transmit it: shipping.Add("return_tracking_number", "SE1234567898XY"); shipping.Add("return_shipping_company", "DHL Germany"); CookComputing.XmlRpc.XmlRpcStruct[] shipment_details = new CookComputing.XmlRpc.XmlRpcStruct[] { shipping }; api.ShipmentInfo.Add("shipment_details", shipment_details);
4. Make the API call
Please initiate the API call to Klarna:
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)
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 );
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.