cancel
Showing results for 
Search instead for 
Did you mean: 

How Cancel or Close an Order.

SOLVED

How Cancel or Close an Order.

I am having a similar problem to this post:

https://magento.stackexchange.com/questions/314427/how-to-cancel-or-close-an-order-that-has-been-inv...

 

Basically my cancel order functionality is no longer working.  I post the /V1/orders/{id}/cancel and it returns only "false".  We don't process a lot of cancellations but this was working when we built it 2 years ago.  

The order is paid for and in the processing state if that helps. 

 

If cancelling will not work is there a logical equivalent like refunding and closing the order? If so what are the API steps required? For example, call the Refund API at XX and then call the close order API at XXYY.

 

Thanks a bunch

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How Cancel or Close an Order.

Hi @stacy1712 

For refund You can use below rest API:

url : http://<base_url>/rest/V1/invoice/{invoiceId}/refund

Method : POST
Token: Admin token

request: 
{
  "items": [
    {
      "extension_attributes": {},
      "order_item_id": 0,
      "qty": 0
    }
  ],
  "isOnline": true,
  "notify": true,
  "appendComment": true,
  "comment": {
    "extension_attributes": {},
    "comment": "string",
    "is_visible_on_front": 0
  },
  "arguments": {
    "shipping_amount": 0,
    "adjustment_positive": 0,
    "adjustment_negative": 0,
    "extension_attributes": {
      "return_to_stock_items": [
        0
      ]
    }
  }
}

For cancel order:
Method: POST
Token: Admin token
URL : 

http://<base_url>/rest/V1/orders/<order_entity_id>/cancel

response : true

cancel_order.png

If issue resolve, please click on 'Kudos' & Accept as Solution!

Problem solved? Click Accept as Solution!

View solution in original post

7 REPLIES 7

Re: How Cancel or Close an Order.

Hi @stacy1712 

For refund You can use below rest API:

url : http://<base_url>/rest/V1/invoice/{invoiceId}/refund

Method : POST
Token: Admin token

request: 
{
  "items": [
    {
      "extension_attributes": {},
      "order_item_id": 0,
      "qty": 0
    }
  ],
  "isOnline": true,
  "notify": true,
  "appendComment": true,
  "comment": {
    "extension_attributes": {},
    "comment": "string",
    "is_visible_on_front": 0
  },
  "arguments": {
    "shipping_amount": 0,
    "adjustment_positive": 0,
    "adjustment_negative": 0,
    "extension_attributes": {
      "return_to_stock_items": [
        0
      ]
    }
  }
}

For cancel order:
Method: POST
Token: Admin token
URL : 

http://<base_url>/rest/V1/orders/<order_entity_id>/cancel

response : true

cancel_order.png

If issue resolve, please click on 'Kudos' & Accept as Solution!

Problem solved? Click Accept as Solution!

Re: How Cancel or Close an Order.

So once an order reaches a certain state it can no longer be canceled and must be refunded?

It might be a good idea to make this issue a top search result for "canceling an order through Magento 2 API."  I have seen countless results that either has no answer or just general confusion on the topic.  Usually with a very robotic response that although correct does not answer the question someone was asking.  

 

Re: How Cancel or Close an Order.


@Bhanu Periwal wrote:

Hi @stacy1712 happy wheels

For refund You can use below rest API:

url : http://<base_url>/rest/V1/invoice/{invoiceId}/refund

Method : POST
Token: Admin token 

request: 
{
  "items": [
    {
      "extension_attributes": {},
      "order_item_id": 0,
      "qty": 0
    }
  ],
  "isOnline": true,
  "notify": true,
  "appendComment": true,
  "comment": {
    "extension_attributes": {},
    "comment": "string",
    "is_visible_on_front": 0
  },
  "arguments": {
    "shipping_amount": 0,
    "adjustment_positive": 0,
    "adjustment_negative": 0,
    "extension_attributes": {
      "return_to_stock_items": [
        0
      ]
    }
  }
}

For cancel order:
Method: POST
Token: Admin token
URL : 

http://<base_url>/rest/V1/orders/<order_entity_id>/cancel

response : true
If issue resolve, please click on 'Kudos' & Accept as Solution!


Thanks guys. It was helpful

Re: How Cancel or Close an Order.


@Bhanu Periwal wrote:

Hi @stacy1712 basketballlegends fun

For refund You can use below rest API:

url : http://<base_url>/rest/V1/invoice/{invoiceId}/refund

Method : POST
Token: Admin token

request: 
{
  "items": [
    {
      "extension_attributes": {},
      "order_item_id": 0,
      "qty": 0
    }
  ],
  "isOnline": true,
  "notify": true,
  "appendComment": true,
  "comment": {
    "extension_attributes": {},
    "comment": "string",
    "is_visible_on_front": 0
  },
  "arguments": {
    "shipping_amount": 0,
    "adjustment_positive": 0,
    "adjustment_negative": 0,
    "extension_attributes": {
      "return_to_stock_items": [
        0
      ]
    }
  }
}

For cancel order:
Method: POST
Token: Admin token
URL : 

http://<base_url>/rest/V1/orders/<order_entity_id>/cancel

response : true

cancel_order.png

If issue resolve, please click on 'Kudos' & Accept as Solution!


Your answer will really help a lot, such answers and topics are always needed, thank you.

Re: How Cancel or Close an Order.

Magento 2 Cancel Order by Meetanshi allows customers to cancel their pending order from the storefront.Magento 2 Cancel OrderMagento 2 Cancel OrderThe competition in E-commerce business is all about offering the best customer experience. For Magento 2 stores, Meetanshi's Magento 2 Cancel Order extension helps in improving the shopping experience of the store.

 

With Magento 2 Cancel Order by Customer extension, let customers cancel their pending orders from "My Account", "My Orders" and order details page in the frontend. The admin is notified via an automated Email about the order cancelation.

 

The Magento 2 Cancel Order extension also lets customers add comments in the confirmation popup that can be seen from the backend. It gives useful data to the admin for improving the products' features and understanding the customers' mindset!

 

Benefits of Magento 2 Cancel Order:

  • Let customers cancel their orders with “Pending” or “Processing” status from "My Account", "My Orders" and order details page in the storefront.
  • Allow customers to add comments in the confirmation popup that appears while canceling the orders.
  • The admin is notified via an automated Email when a customer cancels the order from the storefront.
  • Admin can choose the notification Email template, sender, and receiver.
  • Option to set custom text for the button label and the notice text in the popup.
  • When a customer cancels the order, its status is changed from "Pending" to "Cancel" and the product is restocked.
  • When a customer cancels the order, its status is changed from "Processing" to "Cancel" and the product is restocked.
  • Enhanced shopping experience.
  • Customer convenience for order cancelation.

For more information, visit https://meetanshi.com/magento-2-cancel-order.html

Re: How Cancel or Close an Order.

Moments before the horrific, blasphemous death of flash, the java script version of Happy Wheels has arrived. That was close. Sorry for the delay. Hopefully the fear of losing Happy Wheels did not prevent your restful sleep. If you didn't even know it was in development, then here is your exciting news.  happy wheels

Re: How Cancel or Close an Order.

You can use this extension for Cancel order, Order Cancel extension provides users an option to cancel their order from front-end. The extension is developed to help customers to cancel orders within a customisable time frame by logging into their account section on website.

 

The following link Magento 2 Cancel Order would be useful.