The order can stay unplaced after an offsite authorization only payment

Created on 27 July 2021, over 3 years ago
Updated 8 June 2023, over 1 year ago

Problem/Motivation

This is a follow-on to #2934647: The order can stay unplaced after an offsite payment β†’ and applies when a site uses an offsite payment gateway operating in authorization only mode (e.g. in combination with an order fulfillment workflow). The resolution to the original issue was to ensure the order would be placed in response to the 'Order Paid' event, which in most cases would be triggered by the offsite IGN when recording a successfully captured payment for the whole order amount. However, for authorization only payments the payment is not complete as we're expecting to capture it later on in the order workflow, which means the IGN never places an orderm, leaving is in the same situation as the original issue - if the customer never returns to the site from the offsite gateway the order fails to get placed.

Proposed resolution

There are two approaches to solving this. Either:

1. Allow authorized payments to count towards the total paid for an order and allow the existing order paid subscriber to do its thing. This has the potential to cause problems with 3rd party / custom logic that assumes OrderInterface::getTotalPaid() and OrderInterface::isPaid() refers to capture payments rather than authorized payments.

Or:

2. Add a new 'Order Payment Authorized' event along with e.g. OrderInterface::isPaymentAuthorized, OrderInterface::getTotalAuthorized and OrderInterface::setTotalAuthorized to facilitate the event subscriber placing the order when the full order balance is either paid or authorized.

πŸ› Bug report
Status

Needs work

Version

2.0

Component

Payment

Created by

πŸ‡¬πŸ‡§United Kingdom pstewart

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡·πŸ‡ΊRussia l.telyatnik

    Fixed Error in patch #10:

    TypeError: Argument 2 passed to Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::dispatch() must be an instance of Symfony\Component\EventDispatcher\Event or null, string given, called in /html/web/modules/contrib/commerce/modules/order/src/OrderStorage.php on line 151 Π² Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (строка 89 ΠΈΠ· /html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php)

  • πŸ‡¬πŸ‡§United Kingdom pstewart

    I should note that while I've succesfully used #10 in a development environment to solve the stalled orders issue, I've never put it into production for a few reasons:

    • With the patch I then ran into race condition problems (see #3043180 πŸ› The changes made to the order on the onNotify method are not applied on the onReturn method Fixed ). There has been progress on that issue recently, however I am running a bit behind on Commerce at the moment so haven't tested with the latest fixes.
    • The patch does make a schema change, which I'm reluctant to put into to my production database while there is doubt over the approach taken.
    • While the patch tries to take an approach consistent to how orders become placed on the main authorize + capture workflow, I agree with @zaporylie that a more workflow agnostic approach is required, perhaps something along the lines of what's been done so far or a simpler core-provisioned event subscriber approach, but either way has some configurability to allow authorization workflow site builders to opt in or out of order placement by IGN depending on what the offsite gateway supports.
  • πŸ‡ͺπŸ‡ΈSpain edurenye

    Rebases against 2.x.

    The race condition should be fixed, since #3043180 has been merged.

    I guess we still need discussion regarding the other 2 points that @pstewart mentioned.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 5.7
    last update 11 months ago
    742 pass, 18 fail
  • Status changed to Needs review 11 months ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 11 months ago
    790 pass
  • πŸ‡ͺπŸ‡ΈSpain edurenye

    Fixed a PHP error.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 7 months ago
    793 pass
  • πŸ‡ͺπŸ‡ΈSpain edurenye

    Rebased against 2.x again.

  • πŸ‡ͺπŸ‡ΈSpain edurenye

    Rebased against 2.x again.

Production build 0.71.5 2024