limegrow / ingenico-m2-payments

2 stars 15 forks source link

Transaction sent with same orderId, last_real_order_id not unset #16

Open choussamaster opened 3 years ago

choussamaster commented 3 years ago

Hi In the File Controller/Resume.php a value is set in session for "last_real_order_id" This value is never unset so if Resume is used the user can no more pass new order after that one because the same order id is send to ingenico image

choussamaster commented 3 years ago

a possible solution is to do something like this on Result.php if ($this->_session->getData('last_real_order_id')) { $this->_session->unsetData('last_real_order_id'); $this->_session->unsetData('last_real_order_id'); $this->_session->unsetData('last_order_id'); } to complete ..

andrey-mt commented 3 years ago

I can’t to reproduce the described issue. Magento has never clear last_real_order_id and this doesn’t produce issues usually.

What payment method and what payment setting have you used?

a possible solution is to do something like this on Result.php if ($this->_session->getData('last_real_order_id')) { $this->_session->unsetData('last_real_order_id'); $this->_session->unsetData('last_real_order_id'); $this->_session->unsetData('last_order_id'); } to complete ..

I can't do that because this clear order information on the Order Success Page (checkout/onepage/success). Magento use last_real_order_id to show order increment id for a customer.

choussamaster commented 3 years ago

Hi I'm using only ingenico payment with card I do not know the very precise case to reproduce but on several occasions after having successfully placed a first order I found myself blocked in the impossibility of placing a second one immediately after even disconnecting / reconnecting I debugged the code via xdebug to see that it was still using the old order id from $this->_session->getData('last_real_order_id') one despite the command was completed successfully

andrey-mt commented 3 years ago

Unfortunately, I can't reproduce this using Ingenico Payment and credit card.

Magento sets last_real_order_id to the session not only in the Controller/Resume.php. It sets last_real_order_id when placing order.

Ingenico payment call Magento Order creation process. https://monosnap.com/file/EuAxdTfBKl2OQSs7dc19DN6t45fCMR $this->submit($quote) call $this->submitQuote(...) and reserve new increment id. https://monosnap.com/file/tRBkRq755P6ghb9kr8VUekUIyAHsuu

Magento create order and save order increment id in the session. Payment gateway use this increment id for processing. Payment gateway (Ingenico) return back to the success page and page show last_real_order_id from the session to a customer. Magento and Ingenico never use last_real_order_id for order creation. I think that only two cases can be there. You have some customization that change order processing or you try to process same order many time somehow.

choussamaster commented 3 years ago

Hi @andrey-mt Thank you for taking time to look at this here is the exact scenario Local environment en docker with magento 2.4.1 Luma Template Page /checkout Payment by I do the first payment with success but all those who follow are in error for duplicate order id When clicking on submit button the "requestOrderId()" from Ingenico/Payment/Model/Connector is called first and get an old "last_real_order_id" from checkoutSession https://monosnap.com/file/YSxZyJIzGwgDdGsqklbQ8rssTW7PzT https://monosnap.com/file/wRE0bCMDDklTR0cDLpWjbjoGayE4Ws

after that the placeOrder is called and magento is correctly generating a new last order id and setting it to checkoutSession https://monosnap.com/file/C4GOX8ZXpR5bI8uY2BiDdJjhr9gM0X

But requestOrderId is not called again so the information sent to ingenico was with old data

for cases where payment works is see that requestOrderId is called again after the place Order with InstantPurchase this is the full trace https://monosnap.com/file/hdLQRHkBKKbEvjDsKpTzE2nl7iv9gG Thank you

andrey-mt commented 3 years ago

Maybe I missed something. In my installation 2.4.1 Magento create order in the /rest/default/V1/carts/mine/payment-information request and save last_real_order_id in the session and send data to Ingenico in the next request /ingenico/payment/inline/?alias=m240000000243842&cardbrand=VISA . Method requestOrderId get data from stored session again.

https://monosnap.com/file/H63LuiOySvr3qhdz7z1oL9JOwAma4T