Update metadata

To update the metadata 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.

/*
javascript client side flow to update metadata
*/
// Suspend the Checkout, showing a spinner...
window.collector.checkout.api.suspend();
// ... then call the backend API to set the new metadata
yourSetMetadataRequestFunction();
// ... and finally resume the Checkout after the backend call is completed to update the Checkout
window.collector.checkout.api.resume();

Once in suspend mode, the Checkout metadata can be updated by sending in a new metadata object to the Checkout API from your backend. The content of this request will replace any existing metadata.

Update metadata request

/*
PUT /merchants/123/checkouts/1eec44b5-66d3-4058-a31f-3444229fb727/metadata HTTP/1.1
Host: checkout-api-uat.collector.se
Content-Type: application/json
Authorization: SharedKey bXlVc2VybmFtZTpmN2E1ODA4MGQzZTk0M2VmNWYyMTZlMDE...
*/
{
"metadata": {
"myCustomKey": 1234,
"myComplexObject": {
"firstKey": true,
"CasingIsKept": [1, 2, 3]
}
}
}
Please Note

Please note that this operation cannot be performed if the purchase is completed.

Request Properties

Request headers

HeaderRequiredExplanation
AuthorizationYesThe authorization header is generated with the access credentials (username and shared access key) received from Collector Merchant Services. Instructions on how to generate the authorization header value can be found under the authorization section.

Request Body properties

PropertyRequiredExplanation
metadataNoMetadata object that will replace any existing metadata. Each key in the object must be a string but the value can be any valid JSON value. Providing null will remove any existing metadata.

Important error responses

Error codeError ReasonCause
400Validation_ErrorMetadata object could not be parsed as a valid JSON object.
423Resource_LockedAnother modifying request is currently being executed for the Checkout session. Retry by sending the request again.
900Purchase_Commitment_FoundThe customer has clicked the Complete Purchase button and the Checkout is therefore locked for modifications.
900Purchase_CompletedPurchase is already complete.