checkout / checkout-magento2-plugin

Checkout.com Magento 2 official extension
MIT License
32 stars 32 forks source link

Webhook receives payment info but no order was created #523

Open JamesFX2 opened 1 year ago

JamesFX2 commented 1 year ago

We've updated to 5.2 but we're having an issue where we are receiving payment authorisations and payment captures where no order exists. A quote exists, but no order. I have looked at the access logs for their IP, they definitely clicked the placeorder URL - actually, they clicked it multiple times.

JamesFX2 commented 1 year ago

Wow. You take payment now before the order is created. Are you unfamiliar with the concept of order validation when the quote is submitted. Why would you do this? An item can be out of stock. A product could be disabled. You can't assume that the order will be created.

JamesFX2 commented 1 year ago

@JuliosDnd you need to fix this please.

We upgraded from 4.0.0

image

To 5.2.0

image

Why on Earth would you presume to create an order before the quote is validated?

When you submit a quote, Magento submits it to its Quote Validator

image

This eventually calls the QuoteValidationComposite

For example, https://github.com/magento/magento2/tree/2.4-develop/app/code/Magento/Quote/Model/ValidationRules

It's also extensible, see

https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Quote/etc/di.xml#L110-L120

If you're going to do something like this

The result? We have a load of users who paid us money and have no order.

JamesFX2 commented 1 year ago

I sorted this out with a plugin on the checkout webhook.

Some validation is put on sales_order_place_before event so I needed to (1) create the order (2) prevent the order being created by the original process (3) prevent the payment request from having a new increment id (4) close any orders for failed payments. If any other end users want this, gimme a shout.

stephen-gilbert-cko commented 10 months ago

v5.3.0 introduced a Payment Processing option under plugin Global Settings which will allow you to set "Order First" in line with Adobe Commerce native behaviour.

https://github.com/checkout/checkout-magento2-plugin/releases/tag/5.3.0