-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -364,26 +364,16 @@ public function single($input, $contribution, $recur = FALSE, $first = FALSE) { | |
|
||
// make sure the invoice is valid and matches what we have in the contribution record | ||
if ((!$recur) || ($recur && $first)) { | ||
if ($contribution->invoice_id != $input['invoice']) { | ||
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']) { | ||
throw new CRM_Core_Exception('PayPalProIPN: Invoice values dont match between database and IPN request.'); | ||
} | ||
} | ||
else { | ||
$contribution->invoice_id = md5(uniqid(rand(), TRUE)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. right i see now ok |
||
} | ||
|
||
if (!$recur) { | ||
if ($contribution->total_amount != $input['amount']) { | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. This simplification is fine to me |
||
throw new CRM_Core_Exception('PayPalProIPN: Amount values dont match between database and IPN request.'); | ||
} | ||
} | ||
else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works for me as well |
||
$contribution->total_amount = $input['amount']; | ||
} | ||
|
||
$status = $input['paymentStatus']; | ||
if ($status === 'Denied' || $status === 'Failed' || $status === 'Voided') { | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Yep fine |
||
Civi::log()->debug("Setting contribution status to Cancelled"); | ||
return; | ||
} | ||
|
@@ -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 commentThe 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 commentThe 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 |
||
} | ||
|
||
/** | ||
|
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