MultiSafepay / magento2

MultiSafepay plugin for Magento 2
Open Software License 3.0
18 stars 8 forks source link

Store Credit is returned multiple times on order cancelling #65

Closed yuriichayka closed 1 month ago

yuriichayka commented 5 months ago

Versions:

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 commented 5 months ago

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

vinodsowdagar commented 5 months ago

Hi @yuriichayka ,

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

vinodsowdagar commented 5 months ago

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.

yuriichayka commented 5 months ago

Hi @vinodsowdagar We will check it Thanks

yuriichayka commented 4 months ago

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

vinodsowdagar commented 3 months ago

Hi @yuriichayka ,

Could you send us a support e-mail to integration@multisafepay.com and refer to this Github issue? We would like to ask some more information related with your account to continue investigating this issue.

vinodsowdagar commented 2 months ago

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.

yuriichayka commented 2 months ago

Hello guys,

Any update on this?

vinodsowdagar commented 2 months ago

Hi @yuriichayka ,

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

vinodsowdagar commented 1 month ago

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.

yuriichayka commented 1 month ago

great, thanks

We will test it on our project