Orders are not completed

Created on 29 October 2024, 9 months ago

Problem/Motivation

Order state is not changed to completed after successful payment.

🐛 Bug report
Status

Active

Version

1.0

Component

PayPal Checkout

Created by

🇨🇾Cyprus alex.bukach

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

Merge Requests

Comments & Activities

  • Issue created by @alex.bukach
  • Pipeline finished with Failed
    9 months ago
    Total: 156s
    #324310
  • 🇨🇾Cyprus alex.bukach

    The MR pipeline fails due to unrelated issues.

  • 🇩🇪Germany Anybody Porta Westfalica

    @alex.bukach could you explain the change?
    What's wrong with the current code and how is it solved?

    Can this be reproduced in vanilla Drupal Commerce?

  • 🇩🇪Germany Anybody Porta Westfalica
  • Issue was unassigned.
  • Status changed to Needs work about 2 months ago
  • 🇩🇪Germany Grevil

    @jsacksick, what do you think about the fix? It's pretty unclear, to us, how this fixes the issue.

    Sadly, @alex.bukach did not reply.

  • 🇮🇱Israel jsacksick

    I'm also not sure what this is fixing... There's just too little details.

  • 🇩🇪Germany Grevil

    Sorry, we thought it might relate to 🐛 Orders are not completed Active .

  • We have a similar problem to this one and 🐛 UNPROCESSABLE_ENTITY - ORDER_ALREADY_COMPLETED leads to wrong order state, maybe race condition? Active . I could not reproduce this locally naturally, but i was reproducible when I opened two tabs with the same order and paid both quickly one after another. The later tab then gets a WSOD:

    Drupal\commerce_order\Exception\OrderVersionMismatchException: Attempted to save order 3314 with version 11. Current version is 12. in Drupal\commerce_order\Entity\Order->preSave() (Zeile 719 in /var/www/html/web/modules/contrib/commerce/modules/order/src/Entity/Order.php).

    Without this patch the order gets placed by the first payment (also logged in the order as such) but then surprisingly stays a draft order with logs displaying the same error as in 🐛 UNPROCESSABLE_ENTITY - ORDER_ALREADY_COMPLETED leads to wrong order state, maybe race condition? Active (i.e.ORDER_ALREADY_COMPLETED). When I go back after this WSOD and try to pay again the PayPal button does not open the Popup but throws an error in Drupal (CANNOT_BE_ZERO_OR_NEGATIVE), which makes sense if the order is paid already.

    With this patch based on patch #2, the second payment still gets the WSOD with the same error logged but then the order stays placed as it should. I can still go back and try to pay, but then I get this warning in the Drupal log (nothing else happens):

    Access denied
    Path: /commerce-paypal/checkout-create/paypal_sandbox/3314. Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: The following permissions are required: 'update commerce_order' OR 'update default commerce_order'. in Drupal\Core\Routing\AccessAwareRouter->checkAccess() (line 120 of /var/www/html/web/core/lib/Drupal/Core/Routing/AccessAwareRouter.php).

    Patch #2 did not apply anymore and the $redirect_url can be empty, which is why I re-added the old code (minus the $order->save()) back in the else branch.

Production build 0.71.5 2024