MDVA-35356: Wrong store credit return after canceling partially invoiced order

The MDVA-35356 patch fixes the issue with incorrect store credit return after partially invoiced order cancellation. This patch is available when the Quality Patches Tool (QPT) 1.0.19 is installed. The patch ID is MDVA-35356. Please note that the issue was fixed in Adobe Commerce version 2.4.3.

Affected products and versions

The patch is created for Adobe Commerce version:

Adobe Commerce on cloud infrastructure 2.4.1

Compatible with Adobe Commerce versions:

Adobe Commerce (all deployment methods) 2.3.0-2.4.2

NOTE
The patch might become applicable to other versions with new Quality Patches Tool releases. To check if the patch is compatible with your Adobe Commerce version, update the magento/quality-patches package to the latest version and check the compatibility on the Quality Patches Tool: Search for patches page. Use the patch ID as a search keyword to locate the patch.

Issue

Steps to reproduce:

  1. Create three simple products.

  2. Create a new user and assign store credit (Example: store credit = $10, simple product prices = $100, $200, and $300).

  3. Log in with the above user, and add the three products to the cart.

  4. Check out the three products in the cart, and utilize the store credit for a portion of the order (Example: paid with Check/Money order).

  5. Perform two invoices on the order through the API, one for Product 1 and one for Product 2:

    code language-php
    //endpoint POST {\{baseUrl}}/V1/order/:orderId/invoice    //1st API call:    {    "capture": true,    "items": [    {    "order_item_id": 1,    "qty": 1    }    ],    "notify": true,    "appendComment": false    }    //2nd API call:    {    "capture": true,    "items": [    {    "order_item_id": 2,    "qty": 1    }    ],    "notify": true,    "appendComment": false    }
    
  6. Notice that the store credit is fully applied to the first invoice.

  7. ​Notice that the store credit balance = 0.

  8. Cancel the order, and see that two items are invoiced and that the third item is canceled.

  9. Observe the store credit balance.

Expected results:

The store credit balance is still 0 because the $10 store credit has been invoiced.

Actual results:

The full store credit is returned: the balance is $10.

Apply the patch

To apply individual patches, use the following links depending on your deployment method:

To learn more about Quality Patches Tool, refer to:

For info about other patches available in QPT, refer to Patches available in QPT in our developer documentation.

recommendation-more-help
8bd06ef0-b3d5-4137-b74e-d7b00485808a