I am using the console command to delete an order item so I need also to create a credit memo based on the delete item price and refund the payment to the customer online using API.
I used the following API to credit memo of particular order ITEM based on the order ID:
ENDPOINT: https://dev.com/rest/V1/invoice/{Invoice ID}/refund
{
"items": [
{
"order_item_id": {Order Item ID},
"qty": 1
}
],
"notify": true,
"arguments": {
"shipping_amount": 0,
"adjustment_positive": 0,
"adjustment_negative": 0,
"extension_attributes": {
"return_to_stock_items": [
1
]
}
}
}
When I send the API request it is throwing an issue of
{
"message": "Creditmemo Document Validation Error (s): \ n The back-to-warehouse argument contains a product item that is not part of the original order.",
"trace": "# 0/home/dev/public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Sales\\Model\\RefundInvoice->execute(91371, Array, false, true, false, NULL, Object(Magento\\Sales\\Model\\Order\\Creditmemo\\CreationArguments))\n#1
/home/dev/public_html/pub/index.php(28): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http\\Interceptor))\n#15 {main}"
}
Can you please help me with how to create a credit Memo using API of a particular order?