buckaroo-it / Magento2

Repository containing the Magento2 plugin by Buckaroo
MIT License
28 stars 35 forks source link

Double store credit refunds when a error is received before redirecting to the buckaroo checkout. #989

Open leonhelmus opened 2 months ago

leonhelmus commented 2 months ago

System requirements: Adobe Commerce: 2.4.6-p4 php 8.1 module buckaroo/magento2: v1.46.1

Settings Working buckaroo account fill in the following settings: buckaroo_magento2/account/secret_key buckaroo_magento2/account/merchant_key

Certificate is not added (buckaroo_magento2/account/certificate_file) reason why is that buckaroo gives back an error before it redirects you as a customer to the buckaroo checkout.

ideal is enabled on test account

Steps to reproduce

Expected result

Actual result

Additional info If this function (\Magento\Quote\Model\QuoteManagement::submitQuote) receives an error after the order has been created Magento will rollbackAddresses using this function: \Magento\Quote\Model\QuoteManagement::rollbackAddresses.

This than triggers the dispatch the event sales_model_service_quote_submit_failure which in turn invokes this observer: \Magento\CustomerBalance\Observer\RevertStoreCreditObserver::execute

Afterwards on the same event Buckaroo has this event:

    <event name="sales_model_service_quote_submit_failure">
        <observer name="buckaroo_failed_quote_order" instance="Buckaroo\Magento2\Observer\HandleFailedQuoteOrder"/>
    </event>

Which triggers a cancellation of the order which triggers this function (\Magento\Sales\Model\Order::cancel) Which adds the following event order_cancel_after which triggers the same observer again: \Magento\CustomerBalance\Observer\RevertStoreCreditObserver::execute

I also added this bug to the magento issues since you could also say this is an issue of magento. https://github.com/magento/magento2/issues/38815

Buckaroo-Rene commented 1 week ago

Hi @leonhelmus,

First of al thanks for contacting us. However I noticed that the issue you raised on the Magento side has been closed, and it seems you've implemented your own fix. If there's been an update or you have more information, please share it with us. Otherwise, can we proceed to close this issue?

Thanks!