XM

Cancel Order By Order ID

Path:

POST https://{baseurl}/api-order/orders/user/cancel?orderId={orderId}

This API enables shoppers (customer context) to cancel their orders directly from your e-commerce site. And, this is secured by Authorization Token. An order can be cancelled only if it is placed with in 24 hours and is not shipped. That is, order cancellation is supported only for the these order statuses - Order_Payment_Authorized or Order_Created.

Headers

Content-Type : application/json

Authorization: JWT

x-site-context : { "date": "2020-08-28T02:35:27.787Z", "channel": 12, "account": 5f493c9f30ec2a0007a94fc8", "stage": "sandbox" }

Parameters

Type : query

Name : The 15 character order ID, which is generated after successful checkout.

Required: true

Type: requestBody

Name: The cancellation code and optionally the cancellation message.

Required: true

Sample Request

Path:

POST https://{baseurl}/api-order/orders/user/cancel?orderId=8917-2674-99643
{
"cancellationCode": "3000",
"cancellationMessage": "Customer found better price elsewhere"
}

Response

Response Code: 200

Message: OK

Description: You will see this message when the requested order is successfully cancelled.

{
"orderId": "8917-2674-99643",
"status": "Successfully cancelled order"
}

Error Code: 404

Message: Not Found

Description: You will see this error when the Order ID is not found.

{
"code": "ORDER_NOT_FOUND",
"message": "Order Id Not Found"
}

Error Code: 404

Message: Not Found

Description: You will see this error when the cancellation code is incorrect.

{
"code": "CUSTOMER_ORDER_CANCELLATION_CODE_NOT_FOUND",
"message": "Customer Cancellation Code Not Found"
}

Error Code: 400

Message: Bad Request

Description: You will see this error when the current status of the order doesn't support cancellation.

{
"code": "ORDER_CANCELLATION_INVALID",
"message": "Order status must be ORDER_PAYMENT_AUTHORIZED or ORDER_CREATED"
}

Error Code: 400

Message: Bad Request

Description: You will see this error when the order ID is not provided.

{
"code": "REQUEST_VALIDATION",
"message": "Invalid data in query: should have required property 'orderId'"
}

Error Code: 400

Message: Bad Request

Description: You will see this error when the order is not within the cancellation window.

{
"code": "ORDER_CANCELLATION_INVALID",
"message": "Order was placed more than 24 hours ago"
}

Error Code: 400

Message: Bad Request

Description: You will see this error when the specified order ID is lesser or greater than 15 characters.

{
"code": "REQUEST_VALIDATION",
"message": "Invalid data in body: /orderId should NOT be shorter than 15 characters"
}

Error Code: 400

Message: Bad Request

Description: You will see this error when the user is not authorized to cancel the order.

{
"orderId": "7061-7821-86562",
"status": "User not allowed to cancel"
}

Error Code: 500

Message: Internal Server Error

Description: You will see this error when the account number is incorrect in the x-site-context (for a multi-tenent client).

Change Log

  • June - 2021

  • July - 2020 First updated