* @return bool
* @throws \CiviCRM_API3_Exception
*/
- public function failed(&$objects, &$transaction, $input = []) {
+ public function failed(&$objects, $transaction = NULL, $input = []) {
$contribution = &$objects['contribution'];
$memberships = [];
if (!empty($objects['membership'])) {
}
}
- $transaction->commit();
+ if ($transaction) {
+ $transaction->commit();
+ }
Civi::log()->debug("Setting contribution status to Failed");
return TRUE;
}
* @return bool
* @throws \CiviCRM_API3_Exception
*/
- public function cancelled(&$objects, &$transaction, $input = []) {
+ public function cancelled(&$objects, $transaction = NULL, $input = []) {
$contribution = &$objects['contribution'];
$memberships = [];
if (!empty($objects['membership'])) {
$this->cancelParticipant($participant->id);
}
}
- $transaction->commit();
+ if ($transaction) {
+ $transaction->commit();
+ }
Civi::log()->debug("Setting contribution status to Cancelled");
return TRUE;
}
$contribution->total_amount = $input['amount'];
}
- $transaction = new CRM_Core_Transaction();
-
$status = $input['paymentStatus'];
if ($status == 'Denied' || $status == 'Failed' || $status == 'Voided') {
- return $this->failed($objects, $transaction);
+ $this->failed($objects);
+ return;
}
if ($status === 'Pending') {
Civi::log()->debug('Returning since contribution status is Pending');
return;
}
elseif ($status == 'Refunded' || $status == 'Reversed') {
- return $this->cancelled($objects, $transaction);
+ $this->cancelled($objects);
+ return;
}
elseif ($status !== 'Completed') {
Civi::log()->debug('Returning since contribution status is not handled');
// check if contribution is already completed, if so we ignore this ipn
$completedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
if ($contribution->contribution_status_id == $completedStatusId) {
- $transaction->commit();
Civi::log()->debug('PayPalIPN: Returning since contribution has already been handled. (ID: ' . $contribution->id . ').');
echo 'Success: Contribution has already been handled<p>';
return;
}
- $this->completeTransaction($input, $ids, $objects, $transaction, $recur);
+ $this->completeTransaction($input, $ids, $objects);
}
/**