Get the customer's selected delivery method​
When Acquiring Checkout Information, a data.shipping
object will be available that will reflect the customer's current delivery selection.
If this value is null, there are no selection at that current state of the checkout.
After purchase the selections are included in the order.
There will be four scenarios that can occur for the checkout session regarding the delivery selection:
- We successfully received delivery methods
- And successfully created external shipments.
- But failed to create external shipments.
- We failed to receive delivery methods (and have therefore not been able to create any external shipment)
- And a fallback shipment was set during checkout initialization
- And no fallback shipment was set.
For scenario 1.2, the shipment will not have an externaShipmentId (null). The rest of the information will be provided though, so you will be able to see where the customer intends to get his/hers packages delivered (carrier and servicePoint).
For scenario 2.2, the shipping object will not exist which means that you must handle this manually and create a shipment for your customer based on the delivery address. Also note that the delivery will always be free of charge for the customer.
Below are examples of the JSON structure of the shipping
object for the four scenarios.
- Scenario 1.1. Successfully created external shipment
- Scenario 1.2. Failed to create an external shipment
- Scenario 2.1. Failed to get delivery methods, with fallback
- Scenario 2.2. Failed to get delivery methods, no fallback
// Simplified Get Checkout Information response with focus on shipping and order object
{
"id": "9eec015f-4b97-44be-a711-d22f3af75069",
"data": {
"customer": {...},
...,
"status": "PurchaseCompleted",
"order": {
"orderId": "9ea42d44-5fca-49c1-9864-b29600c7201a",
"totalAmount": 2757,
"items": [
{
"id": "11111",
"description": "Item one",
"unitPrice": 5,
"quantity": 1,
"vat": 25,
"sku": "Item one sku"
},
{
"id": "222222",
"description": "Item two",
"unitPrice": 2,
"quantity": 1,
"vat": 25,
"sku": "Item two sku"
},
{
"id": "Frakt-1",
"description": "Pickup in store",
"unitPrice": 750,
"quantity": 1,
"vat": 25
},
{
"id": "Frakt-2",
"description": "Home delivery",
"unitPrice": 2000,
"quantity": 1,
"vat": 25
}
]
},
"shipping": {
"provider": "DeliveryAdapterName",
"shippingFee": 2750,
"shipments": [
{
"id": "shipmentId-1",
"bookedShipmentId": "ABC",
"feeItemId": "Frakt-1",
"metadata": {
"key-for-shipment": "metadata-for-shipment",
"from-store-id": "1234"
},
"shippingChoice": {
"id": "choiceId-1",
"name": "Pickup in store",
"fee": 0,
"metadata": {
"key-for-choice-1": "metadata-for-choice-1"
},
"destination": {
"id": "destinationId-gothenburg",
"name": "Gothenburg",
"fee": 0,
"metadata": {
"key-for-destination": "metadata-for-destination"
},
"deliveryDate": {
"fee": 0,
"metadata": {
"duringOpenHours": "true"
},
"date": "2021-02-25",
"timeFrom": "07:00",
"timeTo": "17:00"
}
},
"options": [
{
"id": "option-1",
"description": "Rent trailer",
"type": "bool",
"fee": 500,
"value": true
},
{
"id": "option-2",
"description": "Help to pack",
"type": "bool",
"fee": 250,
"value": true
},
{
"id": "option-3",
"description": "Additional information",
"type": "string",
"fee": 0,
"value": "Some info"
}
]
}
},
{
"id": "shipmentId-2",
"externalShipmentId": "DEF",
"name": "Home delivery",
"feeItemId": "Frakt-2",
"metadata": null,
"shippingChoice": {
"id": "choice-home-delivery",
"fee": 1500,
"metadata": null,
"destination": {
"id": "standard-home-delivery",
"name": "Standard, the most comfortable delivery",
"fee": 0,
"metadata": null,
"deliveryDate": null
},
"options": [
{
"id": "option1",
"description": "Bring my old stuff out",
"type": "bool",
"fee": 500,
"value": true
}
]
}
}
]
},
...
},
"error": null
}
// Simplified Get Checkout Information response with focus on shipping and order object
{
"id": "9eec015f-4b97-44be-a711-d22f3af75069",
"data": {
"customer": {...},
...,
"status": "PurchaseCompleted",
"order": {
"orderId": "9ea42d44-5fca-49c1-9864-b29600c7201a",
"totalAmount": 85,
"items": [
{
"id": "11111",
"description": "Item one",
"unitPrice": 5,
"quantity": 1,
"vat": 25,
"sku": "Item one sku"
},
{
"id": "222222",
"description": "Item two",
"unitPrice": 2,
"quantity": 1,
"vat": 25,
"sku": "Item two sku"
},
{
"id": "Frakt-1",
"description": "Pickup in store",
"unitPrice": 78,
"quantity": 1,
"vat": 25
}
]
},
"shipping": {
"provider": "nShift",
"shippingFee": 78,
"shipments": [
{
"id": "shipmentId-1",
"externalShipmentId": null,
"feeItemId": "Frakt-1",
"metadata": {
"key-for-shipment": "metadata-for-shipment",
"from-store-id": "1234"
},
"shippingChoice": {
"id": "choiceId-1",
"name": "Postnord home delivery",
"fee": 49,
"metadata": {
"key-for-choice-1": "metadata-for-choice-1"
},
"destination": {
"id": "destinationId-gothenburg",
"name": "Gothenburg",
"fee": 0,
"metadata": {
"key-for-destination": "metadata-for-destination"
},
"deliveryDate": {
"fee": 0,
"metadata": {
"duringOpenHours": "true"
},
"date": "2021-02-25",
"timeFrom": "07:00",
"timeTo": "17:00"
}
},
"options": [
{
"id": "option-1",
"description": "Express delivery",
"type": "bool",
"fee": 29,
"value": true
}
]
}
}
]
},
...
},
"error": null
}
// Simplified Get Checkout Information response with focus on shipping and order object
{
"id": "9eec015f-4b97-44be-a711-d22f3af75069",
"data": {
"customer": {...},
...,
"status": "PurchaseCompleted",
"order": {
"orderId": "9ea42d44-5fca-49c1-9864-b29600c7201a",
"totalAmount": 17.98,
"items": [
{
"id": "11111",
"description": "Item one",
"unitPrice": 1,
"quantity": 1,
"vat": 25,
"sku": "Item one sku"
},
{
"id": "222222",
"description": "Item two",
"unitPrice": 2,
"quantity": 1,
"vat": 25,
"sku": "Item two sku"
},
{
"id": "9999",
"description": "Shipping cost",
"type": "ShippingFee",
"unitPrice": 14.98,
"quantity": 1,
"vat": 25
}
]
},
"shipping": {
"provider": "MerchantFallback",
"shippingFee": 14.98,
"shipments": [
{
"id": "9999",
"feeItemId": "9999",
"shippingChoice": {
"id": "9999",
"name": "Shipping cost",
"fee": 14.98,
"vat": 25
}
}
]
},
...
},
"error": null
}
// Simplified Get Checkout Information response with focus on shipping and order object
{
"id": "9eec015f-4b97-44be-a711-d22f3af75069",
"data": {
"customer": {...},
...,
"status": "PurchaseCompleted",
"order": {
"orderId": "9ea42d44-5fca-49c1-9864-b29600c7201a",
"totalAmount": 7,
"items": [
{
"id": "11111",
"description": "Item one",
"unitPrice": 5,
"quantity": 1,
"vat": 25,
"sku": "Item one sku"
},
{
"id": "222222",
"description": "Item two",
"unitPrice": 2,
"quantity": 1,
"vat": 25,
"sku": "Item two sku"
}
]
},
...
},
"error": null
}
nShift Delivery Adapter​
If using nShift Delivery Adapter, Walley Checkout will attempt to create a prepared shipment at nShift that is not yet activated.
When we do this we get a prepareId from nShift that we will hand over to you as externalShipmentId
.
When the package is ready to be delivered, you need to activate the delivery by sending a request to nShift with this prepareId. See nShift's documentation how to activate the prepared shipment.