-
-
Notifications
You must be signed in to change notification settings - Fork 828
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
[REF] Cleanup validation in PaypalProIPN single function #20360
Conversation
This fixes interaction with the contribution object to instead use the function and switches the standardised error handling (throw an exception & let it be caught). The contribution object used to be passed to completeOrder but no longer so there is no reason to set total_amount & invoice_id on it (they will be used from input)
(Standard links)
|
@seamuslee001 are you OK to merge this - it's actually pretty straight forward |
} | ||
} | ||
else { | ||
$contribution->invoice_id = md5(uniqid(rand(), TRUE)); |
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.
@eileenmcnaughton do we not need to do this for subsequent recurring contributions?
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.
@seamuslee001 no - I did try to explain in the message template - that contribution doesn't actually 'go anywhere' from here - or at least nowhere that accesses this property
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.
right i see now ok
Civi::log()->debug('PayPalProIPN: Invoice values dont match between database and IPN request.'); | ||
echo "Failure: Invoice values dont match between database and IPN request<p>contribution is" . $contribution->invoice_id . " and input is " . $input['invoice']; | ||
return; | ||
if ($this->getContributionObject()->invoice_id !== $input['invoice']) { |
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.
This simplification is fine to me
Civi::log()->debug('PayPalProIPN: Amount values dont match between database and IPN request.'); | ||
echo "Failure: Amount values dont match between database and IPN request<p>"; | ||
return; | ||
if ($this->getContributionObject()->total_amount != $input['amount']) { |
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.
This simplification is fine to me
} | ||
} | ||
else { |
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.
This works for me as well
@@ -402,7 +392,7 @@ public function single($input, $contribution, $recur = FALSE, $first = FALSE) { | |||
Contribution::update(FALSE)->setValues([ | |||
'cancel_date' => 'now', | |||
'contribution_status_id:name' => 'Cancelled', | |||
])->addWhere('id', '=', $contribution->id)->execute(); | |||
])->addWhere('id', '=', $this->getContributionID())->execute(); |
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.
Yep fine
@@ -419,7 +409,7 @@ public function single($input, $contribution, $recur = FALSE, $first = FALSE) { | |||
return; | |||
} | |||
|
|||
CRM_Contribute_BAO_Contribution::completeOrder($input, $this->getContributionRecurID(), $contribution->id ?? NULL); | |||
CRM_Contribute_BAO_Contribution::completeOrder($input, $this->getContributionRecurID(), $this->getContributionID()); |
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.
Fine
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.
See how repeat other never gets the contribution - so that invoice_id is set but discarded
All seems fine to me now |
Overview
[REF] Cleanup validation in PaypalProIPN single function
Before
Passed in object used for validation. Properties set on the passed-in-object only to be discarded
After
Simplified validation, unused variables not set
Technical Details
This fixes interaction with the contribution object to instead use the function
and switches the standardised error handling (throw an exception & let
it be caught).
The contribution object used to be passed to completeOrder but no longer
so there is no reason to set total_amount & invoice_id on it
(they will be used from input)
Comments