POST /CheckOut2Api/UpdateDeliveryAddress
An option for explicitly change/update the delivery address. Customer loads checkout first and if customer select deliver to pre defined delivery address, delivery address will be replaced and option to change delivery address in the checkout should be forbidden.
How it works:
- Merchant can update DeliveryAddress if checkout is in BeingProcessedState
- Customer loads a checkout
- If merchant provides a selection of delivery address options outside the checkout that customer wants – Merchant can patch DeliveryAddress.
- Merchant will send UpdateDeliveryAddress request with selected address.
- Merchant will send Message to checkout “reloadDeliveryAddress”. This will reload checkout.
- Customer should not be able to change DeliveryAddres until he change Delivery option again. If customer change delivery option merchant has to send UpdateDeliveryAddress request again and reloadDeliveryAddress with same data but with UseDifferentDeliveryAddress = false;
Input parameters
Name | Data Type | Default value | Description |
---|---|---|---|
PurchaseId | Empty String | None. Must be specified | An ID acquired when initializing a Check-Out session |
DeliveryAddress | None. Must be specified | Delivery address object | |
FirstName | String | Delivery First Name | |
LastName | String | Delivery Last Name | |
Address | String | Delivery Address | |
ZipCode | String | Delivery Zip code | |
City | String | Delivery City | |
UseDifferentDeliveryAddress | Boolean | True | True = Change delivery address option not editable in checkout Fales = Change delivery address option editable in checkout |
Example request
{
"PurchaseId": "e422f4b5fb5d4edec496b15556203ea0",
"DeliveryAddress": {
"FirstName": "Kalle",
"LastName": "Andersson",
"Address": "Storgatan 27",
"ZipCode": "50110",
"City": "Borås",
"UseDifferentDeliveryAddress": true
}
}
Example for update ajax request
<script type="text/javascript">
function updateDeliveryAddress(e) {
var id = '@Html.Raw(Model.PurchaseID)';
var url = '/avarda/updateDeliveryAddress?PurchaseId=' + id;
$.ajax({
url: url,
method: 'POST',
data: {
PurchaseId: id,
},
cache: false,
success: function () {
var messagePrefix = 'AvardaCheckOut:';
var message =
messagePrefix + JSON.stringify({ type: 'reloadDeliveryAddress' });
window.parent.postMessage(message, '*');
},
});
}
</script>