Finalize a cart
Use the finalizeCart mutation to finalize a purchase and place an order. This is the last step in the end-to-end Checkout process.
Mutation:
mutation finalizeCart($input: FinalizeCartInput!) {
finalizeCart(input: $input) {
purchaseDetails {
purchaseId
purchaseNumber
}
userErrors {
... on DetailedUserError {
__typename
blockingErrors {
code
itemId
message
messageParameters {
key
value
}
}
errorCode
message
path
status
}
}
}
}
Sample arguments:
{
"input": {
"cartId": "643d307d312f6e1ffbb17efd",
"agreeToTerms": true
}
}
}
Sample output:
{
"data": {
"finalizeCart": {
"purchaseDetails": {
"purchaseId": "25f7dcee-325c-40f9-98ee-019b7d4bc985",
"purchaseNumber": "024283"
}
}
}
}
Error handling
In addition to the common errors that result from requests with invalid data or headers, this mutation can also result in specific user errors when there's a failure in one of the business rules.
Example output:
{
"data": {
"finalizeCart": {
"purchaseDetails": null,
"userErrors": [
{
"__typename": "DetailedUserError",
"message": "Payload is not valid",
"path": [],
"status": 400,
"blockingErrors": [
{
"code": "REQUIRED_FIELD_VALIDATION_ERROR",
"message": "Required field 'UserPrincipleName' has failed validation: The specified username is not valid (contains invalid characters, is 'admin' or is unavailable).",
"itemId": "2719df25-2599-48c0-a0c1-924d06b02c27",
"messageParameters": [
{
"key": "REQUIRED_FIELD_KEY",
"value": "UserPrincipleName",
},
{
"key": "REQUIRED_FIELD_ERROR_MESSAGE",
"value": "Required field 'UserPrincipleName' has failed validation: The specified username is not valid (contains invalid characters, is 'admin' or is unavailable). ",
},
]
}
]
}
]
}
}
}
Error code | Description |
---|---|
SUBSCRIPTION_CUSTOM_ATTRIBUTE_VALIDATIONS_ERROR | This error occurs if the details of the subscription custom attributes are invalid. |
PURCHASE_CUSTOM_ATTRIBUTE_VALIDATIONS_ERROR | This error occurs if the details of the purchase custom attributes are invalid. |
REQUIRED_FIELD_VALIDATION_ERROR | This error occurs if the details of the product fields are invalid. |
INVALID_ITEM_QUANTITIES | This error occurs if the unit quantity value is invalid. |
DAILY_SPEND_LIMIT_EXHAUSTED | This error occurs if the daily spend limit is enabled and the cart value exceeds the limit. |
THIRTY_DAYS_SPEND_LIMIT_EXHAUSTED | This error occurs if the monthly spend limit is enabled and the cart value exceeds the limit for the month. |
DEFAULT_PAYMENT_METHOD_NOT_FOUND | These errors occur if a default payment method is required but is missing. |
PURCHASE_PRE_AUTH_FAILED | This error occurs if the Payment Authorization fails. |
Was this page helpful?
Tell us more…
Help us improve our content. Responses are anonymous.
Thanks
We appreciate your feedback!