Skip to main content

Shipping address callback

When there are changes in the shipping address in the checkout, a callback is sent to session.express.shipping_address_callback with the new address.

The webshop should update the webshop state/order with the new shipping address, and (if shipping in iframe is enabled) return the new list of available shipping options.

Look here for the documentation of the callback.

If the checkout is embedded, the Dintero Web SDK will call onSession whenever the session is updated, with the event SessionUpdated.

Troubleshooting

If correction item is added to the order

If the implementation has problems with items of the type correction, you might have problems with the shipping address callback.

Item with correction
{
"id": "correction-mc7nt6LjqgCejGGLNHpFMq",
"amount": -10000,
"line_id": "correction-mc7nt6LjqgCejGGLNHpFMq",
"quantity": 1,
"description": "Correction"
}

This can happen when handling the callback and responding with an updated order with the wrong order.amount.

To solve this, make sure that order.amount contains the amount from the shipping option which is currently chosen.

Example

If the callback contains the following:

{
"order": {
"items": [
{
"id": "item-1",
"line_id": "item-1",
"amount": 10000,
"vat": 25,
"vat_amount": 2000,
"quantity": 1
}
],
"amount": 20000,
"vat_amount": 4000,
"currency": "NOK",
"shipping_option": {
"id": "shipping",
"line_id": "shipping",
"amount": 10000,
"vat": 25,
"vat_amount": 2000
}
}
}

then, if the order is not changed, the response needs to contain the 10000 from the request order.shipping_option.amount:

{
"order": {
"items": [
{
"id": "item-1",
"line_id": "item-1",
"amount": 10000,
"quantity": 1,
"vat": 25,
"vat_amount": 2000
}
],
"amount": 20000,
"vat_amount": 4000,
"currency": "NOK"
}
}

If the tax of the item has changed from 25% to 20% you should still provide the same amount from the callback payload. If the shipping option price has changed, we will adjust the total price of the whole order when we choose the shipping option from the new list of shipping options.

{
"order": {
"items": [
{
"id": "item-1",
"line_id": "item-1",
"amount": 9600,
"quantity": 1,
"vat": 20,
"vat_amount": 1600
}
],
"amount": 19600,
"vat_amount": 3600,
"currency": "NOK"
}
}
tip

The use-cases for when the order changes when the address is changed are:

  • The new address is in another country or state, and the tax is different for the new location
  • Other, less probable ones (e.g. if the customer is from a certain location, they have to buy a specific item)

If these use cases don't apply to you, it's best to respond to the callback with just the new shipping options.