- Issue created by @ramlev
- Status changed to Closed: works as designed
about 1 year ago 8:46am 11 September 2023 - 🇳🇴Norway zaporylie
I think there's some confusion about the payment and order state. First of all please mind that the payment gateways are only responsible for handling payments, not orders. Therefore in the payment gateway onReturn and onNotify methods, you'll only find references to the payment entity, being saved, and not the order entity. This is by design as onNotify (also known as IPN) and onReturn may be triggered at the same time leading to race conditions.
The following quote is from SupportsNotificationsInterface::onNotify
* This method should only be concerned with creating/completing payments,
* the parent order does not need to be touched. The order state is updated
* automatically when the order is paid in full, or manually by the
* merchant (via the admin UI).I mention this because of this comment of yours:
Bus as far as i can see, if we return the payment.reservation.created.v2 $state will be authorization and the order will still be in draft, and not completed
I think the order state should not be equal the payment state, because the amount have been reserved on the card and the order is complete ?There is no special logic in this module that operates on the order state. This module is only responsible for handling payment (by design - every payment gateway module is). It's commerce core that handles automated placement of the orders paid in full. And in terms of commerce these are payment's that were captured in full (payment has state complete). Here's a code responsible for that https://git.drupalcode.org/project/commerce/-/blob/8.x-2.x/modules/payme...
We've been discussing similar handling for authorized payments for a while now. This work is now tracked in 🐛 The order can stay unplaced after an offsite authorization only payment Needs review - Feel free to read through the comments there to discover some pros and cons, and I encourage you to contribute to the discussion with the ideas.
If you're looking for a temporary solution supported by this module, please check the documentation pages, especially this section: https://www.drupal.org/docs/contributed-modules/commerce-easy/basic-usag... → This is where https://www.drupal.org/project/commerce_payment_extra → is mentioned that will make sure the orders that are locked and in the draft mode are placed automatically if authorized payment is registered (typically via IPN). This should address your concerns.
I hope this comment will help you achieve your goals.
- 🇩🇰Denmark ramlev
The solution with the commerce_payment_extra_order module solves it, thank you for the good explanation