checkout/checkout-magento2-plugin

Webhook receives payment info but no order was created

Opened this issue · 4 comments

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.

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.

@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

  • Minimum Order Amount
  • Billing + Shipping Address Validation
  • Payment Method Validation
  • Shipping Method Validation
  • Allowed Country Validation

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

  • clone the quote
  • pass it into \Magento\Quote\Model\SubmitQuoteValidator

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

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.

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