Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pending Payment Order Lifetime & sales_clean_orders Cronjob Conflict? #37878

Open
5 tasks
drinkingsouls opened this issue Aug 15, 2023 · 13 comments · May be fixed by #37999
Open
5 tasks

Pending Payment Order Lifetime & sales_clean_orders Cronjob Conflict? #37878

drinkingsouls opened this issue Aug 15, 2023 · 13 comments · May be fixed by #37999
Labels
Area: Order Component: Cron Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.6-p2 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@drinkingsouls
Copy link

drinkingsouls commented Aug 15, 2023

Preconditions and environment

  • Reproducible and tested on 2.4.6-p1 and 2.4.6-p2.

The sales_clean_orders cronjob is run every hour, on the hour. This is set it in the crobtab.xml at vendor/magento/module-sales/etc

<job name="sales_clean_orders" instance="Magento\Sales\Model\CronJob\CleanExpiredOrders" method="execute"> <schedule>0 * * * *</schedule> </job>

This cancels orders with "Pending Payment" status correctly. However, it does this once per hour, as set by the cron.

There is a setting to reduce order pending lifetime in Stores > Configuration >Sales > Sales > Orders Cron Settings >Pending Payment Order Lifetime (minutes)
If you set this to anything less than an hour, the order stays in Pending Payment status until the sales_clean_orders cron is run (once an hour), it doesn't trigger the cron any earlier. If the time is set to more than an hour then this setting works as expected. The default setting of 8 hours works as expected.

Steps to reproduce

Navigate to setting:
Stores > Configuration >Sales > Sales > Orders Cron Settings >Pending Payment Order Lifetime (minutes).
Change to a value less than 60 minutes. E.g 10 minutes.

Expected result

Pending Payment orders are Closed when time value set is reached.

Actual result

Payment Pending orders are not Closed until the sales_clean_orders cron is run every hour.

Additional information

I can tell that the time in the Pending Payment Order Lifetime (minutes) is honoured in some way, for example:

If I set the value to 15 minutes and I place an order at 13:50, when the cron sales_clean_orders is ran at 14:00, the order remains pending (as 15 minutes had not passed - 5 minutes remain). This should, in theory, change to Cancelled status at 14:05. In reality it will not be changed to Cancelled until 15:00 when the next sales_clean_order cron is ran.

If the cronjob time for sales_clean_orders is edited down to run more frequently, for example, every five minutes <schedule>*/5 * * * *</schedule> then this runs a bit more accurately as the cron checks for orders to cancel more frequently.

In reality, should the minutes set in "Pending Payment Order Lifetime (minutes)." not dictate how often the sales_clean_orders cron is run?

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Aug 15, 2023

Hi @drinkingsouls. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

@drinkingsouls drinkingsouls changed the title Pending Payment Order Lifetime & sales_clean_orders Conflict? Pending Payment Order Lifetime & sales_clean_orders Cronjob Conflict? Aug 15, 2023
@drinkingsouls
Copy link
Author

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @drinkingsouls. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

@drinkingsouls
Copy link
Author

drinkingsouls commented Aug 15, 2023

Can't be replicated on Dev Instance as there is no Payment Gateway to set "Pending Payment" status to an order.

@engcom-Dash engcom-Dash added the Reported on 2.4.6-p2 Indicates original Magento version for the Issue report. label Aug 16, 2023
@engcom-Dash engcom-Dash self-assigned this Aug 16, 2023
@m2-assistant
Copy link

m2-assistant bot commented Aug 16, 2023

Hi @engcom-Dash. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

    1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    1. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
    1. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

@drinkingsouls
Copy link
Author

drinkingsouls commented Aug 24, 2023

Looks like similar issue to #23682

To simplify, the "Pending Payment Order Lifetime (minutes)" setting is in conflict with the sales_clean_orders cron that only runs once an hour.

If anything less than 60 minutes is set for "Pending Payment Order Lifetime (minutes)", it doesn't cancel Pending Payment orders because it has to wait for the sales_clean_orders cron to be run hourly.

@m2-assistant
Copy link

m2-assistant bot commented Sep 6, 2023

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Bravo
Copy link
Contributor

engcom-Bravo commented Sep 6, 2023

Hi @drinkingsouls,

Thank you for reporting and collaboration.

Verified the issue on Magento 2.4-develop instance and the issue is reproducible.Kindly refer the screenshots.

Steps to reproduce

  • Navigate to setting:
  • Stores > Configuration >Sales > Sales > Orders Cron Settings >Pending Payment Order Lifetime (minutes).
  • Change to a value less than 60 minutes. E.g 10 minutes.
Screenshot 2023-09-05 at 10 18 51 PM Screenshot 2023-09-05 at 11 39 12 PM

Pending Payment orders are not Closed when time value set is reached.

Hence Confirming the issue.

Thanks.

@engcom-Bravo engcom-Bravo added Area: Order Component: Cron Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. labels Sep 6, 2023
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-9466 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented Sep 6, 2023

✅ Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@drinkingsouls
Copy link
Author

Pending Payment orders are Closed when time value set is reached.

Pending Payment orders are not closed when time value set is reached. That is the problem.

@rogerdz rogerdz linked a pull request Sep 19, 2023 that will close this issue
5 tasks
@MilenV
Copy link

MilenV commented Dec 13, 2023

Hello Team,

We observe the following issue.
We have a lot of orders stuck in "Pending Payment" after these orders have been "Refunded".
Example order is 002006663.
Pending Payment

Nov 14, 2023 4:57:05 PM Pending Payment Customer Not Notified Refund Webhook successfully handled Nov 14, 2023 4:57:05 PM Pending Payment Customer Not Notified Adyen HTTP Notification(s): eventCode: REFUND pspReference: VRCQBWR6W46XZP52 paymentMethod: visa success: true Nov 14, 2023 4:54:22 PM Pending Payment Customer Not Notified Refunded by D.T. 231114-000235 Nov 14, 2023 4:54:12 PM Closed Customer Not Notified We refunded £35.44 online. Transaction ID: "GS3GQ3GJHVM89VB2-capture-refund" Nov 14, 2023 4:54:12 PM Processing Customer Not Notified Adyen Result response: authResult: [refund-received] pspReference: VRCQBWR6W46XZP52 Oct 18, 2023 10:07:33 PM Complete Customer Not Notified Oct 18, 2023 10:03:15 PM Complete Customer Not Notified Oct 18, 2023 10:03:14 PM Processing Customer Not Notified Captured amount of £35.44 online. Transaction ID: "GS3GQ3GJHVM89VB2-capture" Oct 18, 2023 10:03:14 PM Exported Customer Not Notified Adyen Result response: authResult: [capture-received] pspReference: BHQ2X7RLKQZMWPG2 Oct 17, 2023 6:02:59 AM Exported Customer Not Notified Oct 16, 2023 11:17:05 PM Sent to Fullfilment Customer Not Notified Oct 16, 2023 11:01:09 PM Processing Customer Not Notified Capture Mode set to Manual Oct 16, 2023 11:01:09 PM Processing Customer Not Notified AUTHORISATION webhook notification w/amount GBP 35.44 was processed Oct 16, 2023 11:01:09 PM Payment Review Customer Not Notified Adyen HTTP Notification(s): eventCode: AUTHORISATION pspReference: GS3GQ3GJHVM89VB2 paymentMethod: visa success: true reason:004385:9205:06/2025 Oct 16, 2023 10:41:30 PM Payment Review Customer Not Notified We will authorize £35.44 after the payment is approved at the payment gateway. Oct 16, 2023 10:41:30 PM Customer Not Notified Adyen Result response: authResult: IdentifyShopper

I have checked the following article https://magento.stackexchange.com/questions/280686/pending-payment-order-lifetime-doesnt-expire-or-cancel-orders where it says that:

The "Pending Payment Order Lifetime" is only related to orders which are in the state "Pending Payment", e.g. if the customer has entered the online transaction payment process and cancels or quits the payment process. Then the order in Magento 2 will stay in the state "Pending Payment". After the timeout of "Pending Payment Order Lifetime" is reached, these orders will be automatically canceled by the Magento cronjob.

In admin panel of Adobe Commerce (known as Magento) here is what configuration have been settled.
Stores==>Configuration==>Sales==>Orders Cron Settings(Pending Payment Order Lifetime (minutes) is 480 mins or 8 hours.
image
Furthermore on Stores==>Configuration==>Sales==>Order Cancelling(time to cancel is 72 hours) this status "Pending Payment" is not selected.
image

The questions that we have as exposed as follows.

  1. If we select "Pending Payment" in Stores==>Configuration==>Sales==>Order Cancelling this will make these orders that stuck in this status "Pending Payment" but being "Refunded" to cancelled as we have sales_cron_job picked them up?
    image
  2. As we already have set "Pending Payment Order Lifetime" to 480 mins or 8 hours why our orders still stuck in "Pending Payment" ?

Default order states in Magento include: "Pending Payment" – assigned to an order for which the payment has been initiated but is awaiting confirmation.
Please note that status of the invoice is paid for all of affected orders.

Regards,
Milen Velinov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Order Component: Cron Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.6-p2 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Status: Ready for Development
Development

Successfully merging a pull request may close this issue.

5 participants