The purpose of the StoreOrder method is to be able to store a virtual order/shipment in the cloud and reuse the data in other nShift Ship without having to pass all the data via other systems.
The StoreOrder method is available through Shipment Server. It will save shipment data as JSON which can then be retrieved later when needed. The solution is especially useful if you use ShipAdvisor 2.0 in a checkout solution and produce shipments via nShift On-premises, e.g. have a Klarna integration. Data can then be imported effortlessly using the OrderId in the import file.
Learn about the following topics in this article:
- Usage with ShipAdvisor 2.0
- Usage with nShift Checkout
- Shipment Server request and response examples
- Setup in nShift On-premises
Use case - ShipAdvisor 2.0
This section will describe a typical use case flow for the StoreOrder functionality.
You are a client who has a webshop and a checkout solution using ShipAdvisor 2.0:
- A consumer enters the checkout of your webshop. One or more GetShipAdvise requests are sent from your checkout to ShipAdvisor 2.0. (ShipAdvisor is used to display shipping alternatives, delivery times, prices etc. Read more).
- When the consumer has finished the payment, a StoreOrder request is sent to Shipment Server to store data about the order. in the OrderStorage webservice. You provide the OrderId in the request and we recommend generating a GUID for this purpose. Save it on the order in your ERP/ WMS so you can import it to nShift On-premises later. If you are using nShift's Klarna integration in your flow, the StoreOrder request will happen on the Klarna "confirm" request.
See the example request and response below.
-
In the import file sent to nShift On-premises to produce the shipment, you must include the clientId in the field ShipAdvisor Reference->Reference. This will trigger the import of the stored order data into nShift On-premises. Note that data in the import file will always override any stored data. If the same field is present in the data stored using the StoreOrder method, it will be overwritten by the data in the corresponding field in the import file.
Example 1: StoreOrder request has the value “John” in Receiver name 1. Receiver Name 1 in the import file has the value “Bill” => “Bill” will be used on shipment.
Example 2: StoreOrder request has the value "John" in Receiver Name 1. Receiver Name 1 in the import file has no value => “John” will be used on shipment.
Usage with Delivery Checkout
When you store the order in Delivery Checkout, you assign a prepareid to the order. This prepareid is then used to locate the order in nShift Ship. See the sample request to create shipments from Delivery Checkout.
Go to Delivery Checkout documentation
Shipment Server request and response sample
HTTP-method: POST
Content-Type: multipart/form-data.
Orderid in options should be one of the following:
- the prepareid from nShift Checkout
- tms_reference from klarna
Sample request: StoreOrder
{
"data": {
"Kind": 1,
"Addresses": [
{
"Kind": 1,
"Name1": "Test Name1",
"Street1": "Test Address 1",
"PostCode": "11825",
"City": "Stockholm",
"Phone": "004612341234",
"Mobile": "004612341234",
"Email": "noreply@dmain.com",
"Attention": "Test Attention",
"CountryCode": "SE"
}
],
},
"options": {
"OrderId": "9f8dc56b-5c33-4bfe-9d41-6a49a5f705cd"
},
"key": "sample",
"actor": "1234",
"command": "StoreOrder"
}
Response:
Note: Goods line information is often managed in the warehouse. It is therefore not recommended to store any goods line information (Shipment.Lines) in OrderStorage. Storing this and importing goods line data will cause duplicate goods lines on shipment.
{
"clientId": "3200123456",
"orderGuid": "5e9dc1ae-d170-455e-8305-fd489b1e5ea3",
"responseStatus": {
"code": "Success",
"messages": []
}
}
The “clientId” is the one that should be used in the ShipAvisor Import setup item - see the next section for more details.
We recommend that you do not store sender and lines in OrderStorage. Lines stored in OrderStorage will be appended to the shipment when importing goodslines.
Example:
- You store a line in StoreOrder with 1 package, 2 kg.
- After packing your ERP/WMS send 1 package, 0,5 kg through Import, you will then end up with 1 shipment with 2 packages on 2 and 0,5 kg.
When using Import you need to provide a carrier code that corresponds with the ProdCSid in StoreOrder.
Sample request: SubmitShipment
{ "Kind": 1, "ActorCSID": "1234", "OrderNo": "SomeOrderNumber", "ProdConceptID": 1782, "References": [ { "Kind": 12, "Value": "SomeReference" } ], "Lines": [ { "PkgWeight": 2000, "Height": "150", "Length": "150", "Width": "150", "References": [ { "Kind": 23, "Value": "Hats" } ], "PkgVol": 0, "GoodsTypeKey1": "", "Pkgs": [ { "ItemNo": 1 } ] } ] }
Setup in nShift On-premises
In nShift On-premises, open the setup item under Setup > ShipAdvisor Import.
The Client ID under the ShipAdvisor 2 tab should be the installation ID of the actor that ShipAdvisor 2.0 uses.
In your Import Setup, you must include the field ShipAdvisor Reference->Reference and use this to include the OrderId in your import file.