Webhooks question

Created on 11 September 2023, about 1 year ago
Updated 12 September 2023, about 1 year ago

When enabling the webhook support, it's possible to get either of two webhooks to be returned from the NETS Easy gateway

payment.reservation.created.v2 or payment.charge.created.v2

If we disable "Authorize and capture", then the payment will only be reserved on the gateway, and for a webshop with physical products, it's the way to do it.

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 ?

Does it make any sense ?

💬 Support request
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

🇩🇰Denmark ramlev

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ramlev
  • Status changed to Closed: works as designed about 1 year ago
  • 🇳🇴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

Production build 0.71.5 2024