-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
WIP Refactor cancel/failed functions in baseIPN so we don't duplicate code and business logic is separated out #14397
Conversation
(Standard links)
|
f5c6aa6
to
5b0ac26
Compare
Does this PR effect the same logic for failed/cancelled event contributions? |
@magnolia61 No changes to existing logic which does mark participants as cancelled if contribution is cancelled/failed (when triggered via the IPN callback) https://github.com/civicrm/civicrm-core/pull/14397/files#diff-e45a4598f8d66f6a82d08e8d4d22ed81R325 |
@mattwire looks good for me. I'm not an IPN expert, but i agree it's the correct path to start organizing better the Contribution code mess 👍 |
@mattwire so there are different ways to de-fang toxic code. I would generally advocate for splitting out small functions & a series of refactors smaller than this, in conjunction with unit tests in the first instance. However, this is tricky because it does a bunch of stuff that seems odd & wrong & paypal specific even though it doesn't live on the paypal class and yet there is a remote possibility other processors use some of it There are crazy things like
in there. Which don't make any sense in the context of a a failing contribution and certainly not in the context of our preferred recurring flow being to create a pending contribution using repeattransaction (status = pending) and then update the contribution depending on the result. My instinct is to
Unless Paypal IPN is the actual focus of what you are trying to achieve here I think messing with it introduces a lot of risk for code that is of very little quality & value in this case. |
@eileenmcnaughton Perhaps this looks more complex that it actually is? All we're actually doing here is merging two identical functions - the only difference is the log message at the start and end. And we extract the two bits of business logic ( I'm planning to do lot's more cleanup as part of the Stripe MIH and implementing Contribution.cancel / Contribution/fail APIs could well be part of that. But we can't deprecate existing code until we have an alternative. And we don't really want to add new code until we understand what it needs to do. There is also some existing test coverage here:
|
5b0ac26
to
eee741e
Compare
This is stale & I'm pretty sure it's because I merrged a recut of this - closing |
Overview
In https://lab.civicrm.org/dev/core/issues/927 we identify some undesirable "business logic" related to cancelling of memberships if a contribution is cancelled. This is a refactor of the BaseIPN class to remove duplicate code and separate out the functions which cancel memberships / participants when a contribution is marked cancelled / failed. This does not "fix" 927 but gets us one step closer to having the code responsible in one place!
Next steps could be to share the
cancelMembership()
/cancelParticipant()
functions withCRM_Contribute_BAO_Contribution::cancel()
Before
BaseIPN has almost identical code duplicated for
cancelled()
andfailed()
actions.After
BaseIPN has shared code for
cancelled()
andfailed()
actions. Participant and Membership related actions are moved into their own functions.Technical Details
There should be no change to behaviour here.
Comments
@sluc23 Could anyone from your team review this? @eileenmcnaughton More contribution actions refactoring here... :-)