Skip to content

Commit

Permalink
Make sure we create a ParticipantPayment record for each participant …
Browse files Browse the repository at this point in the history
…in an event registration
  • Loading branch information
mattwire committed Oct 20, 2019
1 parent c32b64a commit d0595a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
2 changes: 0 additions & 2 deletions CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1474,15 +1474,13 @@ public function submit($params) {
}

// Insert payment record for this participant
if (empty($ids['contribution'])) {
foreach ($this->_contactIds as $num => $contactID) {
$participantPaymentParams = [
'participant_id' => $participants[$num]->id,
'contribution_id' => $contributions[$num]->id,
];
civicrm_api3('ParticipantPayment', 'create', $participantPaymentParams);
}
}

// CRM-11124
if ($this->_params['discount_id']) {
Expand Down
23 changes: 9 additions & 14 deletions CRM/Event/Form/Registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -731,24 +731,19 @@ public function confirmPostProcess($contactID = NULL, $contribution = NULL) {
'Participant'
);

$createPayment = (CRM_Utils_Array::value('amount', $this->_params, 0) != 0) ? TRUE : FALSE;

// force to create zero amount payment, CRM-5095
// we know the amout is zero since createPayment is false
if (!$createPayment &&
(isset($contribution) && $contribution->id) &&
$this->_priceSetId &&
$this->_lineItem
) {
$createPayment = TRUE;
if ($contribution) {
$contributionID = $contribution->id;
}
elseif (CRM_Utils_Array::value('contributionID', $this->_params)) {
$contributionID = $this->_params['contributionID'];
}

if ($createPayment && $this->_values['event']['is_monetary'] && !empty($this->_params['contributionID'])) {
$paymentParams = [
if (!empty($contributionID)) {
$participantPaymentParams = [
'participant_id' => $participant->id,
'contribution_id' => $contribution->id,
'contribution_id' => $contributionID,
];
civicrm_api3('ParticipantPayment', 'create', $paymentParams);
civicrm_api3('ParticipantPayment', 'create', $participantPaymentParams);
}

$this->assign('action', $this->_action);
Expand Down

0 comments on commit d0595a0

Please sign in to comment.