return self::$_exportableFields;
}
+ /**
+ * @param $contributionId
+ * @param $paymentType
+ * @param $participantId
+ *
+ * @param $financialTrxn
+ */
+ protected static function recordPaymentActivity($contributionId, $participantId, $financialTrxn) {
+ $activityType = ($financialTrxn->total_amount < 0) ? 'Refund' : 'Payment';
+ if ($participantId) {
+ $inputParams['id'] = $participantId;
+ $values = [];
+ $ids = [];
+ $component = 'event';
+ $entityObj = CRM_Event_BAO_Participant::getValues($inputParams, $values, $ids);
+ $entityObj = $entityObj[$participantId];
+ }
+ else {
+ $entityObj = new CRM_Contribute_BAO_Contribution();
+ $entityObj->id = $contributionId;
+ $entityObj->find(TRUE);
+ $component = 'contribution';
+ }
+
+ self::addActivityForPayment($entityObj, $financialTrxn, $activityType, $component, $contributionId);
+ }
+
/**
* @inheritDoc
*/
}
}
- // activity creation
if (!empty($financialTrxn)) {
- if ($participantId) {
- $inputParams['id'] = $participantId;
- $values = array();
- $ids = array();
- $component = 'event';
- $entityObj = CRM_Event_BAO_Participant::getValues($inputParams, $values, $ids);
- $entityObj = $entityObj[$participantId];
- }
- else {
- $entityObj = new CRM_Contribute_BAO_Contribution();
- $entityObj->id = $contributionId;
- $entityObj->find(TRUE);
- $component = 'contribution';
- }
- $activityType = ($paymentType == 'refund') ? 'Refund' : 'Payment';
-
- self::addActivityForPayment($entityObj, $financialTrxn, $activityType, $component, $contributionId);
+ self::recordPaymentActivity($contributionId, $participantId, $financialTrxn);
return $financialTrxn;
}