magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Store Credit is returned multiple times on order cancelling

Open yuriichayka opened this issue 10 months ago • 5 comments

Versions:

  • multisafepay/magento2: 3.1.0
  • Adobe Commerce: 2.4.5-p6

When using declined Mastercard number and pressing 'Cancel' button - Store Credit is returned twice for a user As result, customer ends up with more store credit then before placing order

To Reproduce

  1. Add some store credit to the customers account with value lower than order's value; See info: https://experienceleague.adobe.com/en/docs/commerce-admin/customers/customer-accounts/store-credit/store-credit
  2. Proceed to checkout, select Store Credit option for payment;
  3. Select Mastercard MSP payment method;
  4. Place order
  5. On MSP payment page, try using declined test credit card number - 4012001037461114
  6. When placing order fails, click on the 'Cancel' button Screenshot from 2024-04-17 16-24-57

Expected behavior Store Credit is returned once regardless of a way for cancelling order

Additional context The problem happens because there are three cases which trigger order cancelling with MSP

  1. By magento, when restoring quote - vendor/magento/module-checkout/Model/Session.php:563
  2. By MSP, when cancelling already created order by pressing on 'Cancel' button We fixed it by applying some additional logic in the RevertStoreCreditForOrder, so cancelling happens only once in a scope of one request - \Magento\CustomerBalance\Observer\RevertStoreCreditForOrder::execute
  3. By MSP, when Declined card payment failed and webhook to magento is sent Why MSP sends cancel order update to Magento on declined card? What if user has another card to use

yuriichayka avatar Apr 17 '24 14:04 yuriichayka

Can you disable cancelling order by webhook to Magento when using declined Cards, or for similar situations? Because Magento already has logic for auto-cancelling pending orders - https://experienceleague.adobe.com/en/docs/commerce-admin/stores-sales/order-management/orders/order-scheduled-operations

yuriichayka avatar Apr 17 '24 14:04 yuriichayka

Hi @yuriichayka ,

Thank you for the report, we will look into it and come back to you later.

vinodsowdagar avatar Apr 17 '24 14:04 vinodsowdagar

Hi @yuriichayka ,

Could you try and test this feature on the latest version of our module? We've made a change in version 3.3.2 where we only set the order canceled once for the webhook and not when the cancel button is pressed to prevent these situations: https://github.com/MultiSafepay/magento2/releases/tag/3.3.2

Please let us know if this fixes your issue, if not we can always investigate further and decide from there.

vinodsowdagar avatar Apr 18 '24 15:04 vinodsowdagar

Hi @vinodsowdagar We will check it Thanks

yuriichayka avatar Apr 18 '24 15:04 yuriichayka

Hi @vinodsowdagar,

Unfortunately the issue still persist in version 3.3.2 with the steps described in description Please check/fix

Screenshot from 2024-05-10 16-28-16

yuriichayka avatar May 10 '24 14:05 yuriichayka

Hi @yuriichayka ,

Could you send us a support e-mail to [email protected] and refer to this Github issue? We would like to ask some more information related with your account to continue investigating this issue.

vinodsowdagar avatar Jun 21 '24 07:06 vinodsowdagar

Hi @yuriichayka ,

First of all I want to thank you for your cooperation in helping us retrieve the proper means to debug this issue! We've successfully confirmed and reproduced this issue and are working on a fix now.

We'll keep you informed in the meantime.

vinodsowdagar avatar Jul 12 '24 09:07 vinodsowdagar

Hello guys,

Any update on this?

yuriichayka avatar Aug 02 '24 07:08 yuriichayka

Hi @yuriichayka ,

We have planned a new release with a fix for this issue early next week. We'll keep you updated.

vinodsowdagar avatar Aug 02 '24 08:08 vinodsowdagar

Hi @yuriichayka ,

We've created a new release with a fix for this issue in it: https://github.com/MultiSafepay/magento2/releases/tag/3.7.1

If there are any questions let us know and we will reopen this issue. For now i am closing this as fixed.

vinodsowdagar avatar Aug 06 '24 15:08 vinodsowdagar

great, thanks

We will test it on our project

yuriichayka avatar Aug 07 '24 08:08 yuriichayka