Update fees
To update the shipping fee while the Checkout is rendered on the screen, a call to the Checkout Client API's suspend() function shall be performed before calling the Checkout Backend API.
Suspend and resume flow​
/*
javascript client side flow to update Fees
*/
// Suspend the Checkout, showing a spinner...
window.walley.checkout.api.suspend();
// ... then call the backend API to set the new Cart
yourSetFeesRequestFunction();
// ... and finally resume the Checkout after the backend call is completed to update the Checkout
window.walley.checkout.api.resume();
The shipping fee is updated by sending a fee object to the Checkout API from your backend. The fee is optional but will be shown last on the receipt after all the cart items if present and be presented separately on the thank you-page.
Once the backend request has completed, a call to the Checkout Client API's resume()
function shall be made to update the state of the Checkout session.
Update fees request​
- Request
- Response
- Error
/*
PUT /checkouts/1eec44b5-66d3-4058-a31f-3444229fb727/fees HTTP/1.1
Host: api.uat.walleydev.com // (Please note! Different hostname in production)
Authorization: Bearer bXlVc2VybmFtZTpmN2E1ODA4MGQzZTk0M2VmNWYyMTZlMDE...
Content-Type: application/json
*/
{
"shipping": {
"id": "shipping1",
"description": "Shipping fee (incl. VAT)",
"unitPrice": 59,
"vat": 25
}
}
{
"id": "f5f4e86d-95b1-4c1a-8ad0-1d5907236bd7",
"data": null,
"error": null
}
/*
Example error. More errors available below.
*/
{
"id": "f5f4e86d-95b1-4c1a-8ad0-1d5907236bd7",
"data": null,
"error": {
"code": 423,
"message": "The resource requested is currently locked for modification. Try again.",
"errors": [
{
"reason": "Resource_Locked",
"message": "The resource requested is currently locked for modification. Try again."
}
]
}
}
Please note that this operation cannot be performed if the Checkout session has expired.
Request Properties​
Request headers
Header | Required | Explanation |
---|---|---|
Authorization | Yes | Instructions on how to generate the authorization header value can be found here. |
To set the shipping fee, add a shipping
object to the fees object of the request. The shipping object can be null
to remove the shipping fee for the current Checkout.
The shipping
object contain the following properties:
Property | Required | Explanation |
---|---|---|
id | Yes | An id of the fee item. Max 50 characters. The combination of id and description (property below) must be unique within the Checkout session including the articles in the cart. Values are trimmed from leading and trailing white-spaces. Shown on the invoice or receipt. |
description | Yes | Descriptions longer than 50 characters will be truncated. Description and id (property above) must be unique within the Checkout session including the articles in the cart. Values are trimmed from leading and trailing white-spaces. Shown on the invoice or receipt. |
unitPrice | Yes | The unit price of the fee including VAT. Allowed values are 0 to 999999.99 . Max 2 decimals, i.e. 25.00 |
vat | Yes | The VAT of the fee in percent. Allowed values are 0 to 100 . Max 2 decimals, i.e. 25.00 |
Important error responses​
Error code | Error Reason | Cause |
---|---|---|
400 | Duplicate_Articles | Can't add article/fees since multiple articles/fees with same id and description already exist. |
400 | Validation_Error | The request contains properties with invalid values. Details are provided in the response body. |
423 | Resource_Locked | Another modifying request is currently being executed for the Checkout session. Retry by sending the request again. |
900 | Purchase_Commitment_Found | The customer has clicked the Complete Purchase button and the Checkout is therefore locked for modifications. |
900 | Purchase_Completed | Purchase is already complete. |