Closed (fixed)
Project:
Commerce Recurring Framework
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Jul 2018 at 15:54 UTC
Updated:
20 Feb 2019 at 09:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
josebc commentedComment #3
josebc commentedforgot handleDecline method oops
Comment #6
josebc commentedFix error
Comment #7
joachim commentedDecline exceptions need to be handled specifically, to tell the job to retry.
What your patch should be doing instead is handling the more general PaymentGatewayException as a second catch() block, which then does something else.
Comment #9
bojanz commentedheddn had the right fix for this in #2988470: Don't initiate payment of an already paid recurring order:
EDIT: Actually, advancedqueue already does this for us. In Processor.php we have:
So, sounds like we don't need to do anything?
Comment #10
bojanz commented@josebc
You said:
What's in that exception? Perhaps it's AcceptJs that is buggy?
Comment #11
joachim commented> EDIT: Actually, advancedqueue already does this for us. In Processor.php we have:
> So, sounds like we don't need to do anything?
Not quite.
If we let advancedqueue catch this, then the job is treated as failed, and won't be retried, which is fine.
But we are left with:
- a recurring order in state 'needs_payment', rather than the more accurate 'failed'
- a subscription that is in state 'active', rather than move to the unpaidSubscriptionState
What we need is the part of handleDecline() that deals with the final attempt at dunning to clean up when an \Exception is caught.
Comment #12
joachim commentedHere's a patch.
I'm not too keen on the need to save the order outside of the new markOrderAsFailed() method, but I assume that handleDecline() saves only at the end in case the RecurringEvents::PAYMENT_DECLINED has subscribers that change the order.
There is an inconsistency that we should maybe think about:
When dunning fails, we treat the job as having succeeded:
When there's an \Exception, it seems logical to me to treat the job as having failed:
But that means that the same result -- an order that's marked as failed -- can be counted as a successful job, or as a failed job.
Comment #13
joachim commentedUpdated patch, with tests.
(Though branch tests are failing, so they're not going to get run here...)
Comment #14
jsacksick commentedCommitted a slightly different patch (Added a $save_order parameter to handleFailedOrder and updated the dependencies in RetryTest).