-
-
Notifications
You must be signed in to change notification settings - Fork 827
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
dev/core#253: Cancelling or An Error during event registration payment should cancel all additional participates #12457
Conversation
(Standard links)
|
I'm not sure about the meta-issue here (ie. what is right from a user POV - others may have opinions.) Cancelling a PAYMENT doesn't seem to me to necessarily cancel the underlying order From the code POV - we should move the handling out of the IPN class & consider whether to have a Contribution.cancel api - or whether calling Contribution.create with status of Cancelled should update related entities as described (& we can test this api of course). @JoeMurray ping |
* fully but the calls to the POST happen in more than one function | ||
* keeping this as good example of data to bring back to life later | ||
|
||
public function testMainFunctionActions() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is nothing lost by this removal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, just the commented out code is removed. but you are welcome to double check :)
…t should cancel all additional participates
But the current code already cancel the main participant, so it does make sense to cancel the additional ones which is what this PR do, but if you mean that the even the cancellation for the main participant should not also happen then that's another matter.
I already thought of that while working on it, but I was bit busy and doing such change require some time and thinking about a proper design for this and where should this logic be moved, so I decided to stick on the minimal change possible.
hmmm maybe, I'll have to think about both options. |
I have been mulling this & I think a Contribution.cancel (& possibly a Contribution.fail) api make sense - mostly because I'm a bit scared to change the existing behaviour of Contribution.create at this stage in the api series. @JoeMurray thoughts? |
@omarabuhussein I think your fix is correct but I agree with @eileenmcnaughton that we need to push for a little bit of code improvement at the same time. I see that
|
Thanks both, I have a lot to follow with these days but will try to get to work on this as soon as possible. |
Just circling back on this - I agree that calling the api is better than by-passing hooks etc and that this is a fairly small change with additional test coverage. Obviously the additional steps haven't happened but I think the presence of unit tests outweighs that concern at this stage |
Problem
If a user is registering for an event with additional participates, and for some reason the payment failed or the user decided to cancel the payment, then only the main user participant record will be set to "cancelled", the rest of additional participants will stay at "pending incomplete transaction" status.
Solution
All participants statuses should be changed to cancelled and not just the main user, Also there should be an activity created for each participants that indicate the event registration is cancelled similar to what happen if the payment succeeded.
Technical notes
The cancelled() and failed() methods of CRM_Core_Payment_BaseIPN class use an instance of the Participant DAO class to change the status to cancelled which results in only changing the first participant :
https://github.com/civicrm/civicrm-core/blob/master/CRM/Core/Payment/BaseIPN.php#L377
https://github.com/civicrm/civicrm-core/blob/master/CRM/Core/Payment/BaseIPN.php#L280
which should be replaced with either a call to Participant BAO create method, or the Participant API to fix the issue.