Skip to content

Commit

Permalink
Merge pull request #15500 from eileenmcnaughton/part_cleanup
Browse files Browse the repository at this point in the history
Switch creation of ParticipantPayment to use API
  • Loading branch information
eileenmcnaughton authored Oct 14, 2019
2 parents 62ef7a8 + f55a8ac commit 3bb78d8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions CRM/Event/Cart/Form/Checkout/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ public function registerParticipant($params, &$participant, $event) {
$participant->save();

if (!empty($params['contributionID'])) {
$payment_params = [
$participantPaymentParams = [
'participant_id' => $participant->id,
'contribution_id' => $params['contributionID'],
];
CRM_Event_BAO_ParticipantPayment::create($payment_params);
civicrm_api3('ParticipantPayment', 'create', $participantPaymentParams);
}

$transaction->commit();
Expand Down
18 changes: 10 additions & 8 deletions CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1316,13 +1316,14 @@ public function submit($params) {
$participants[0]->id,
'Participant'
);
//add participant payment
$paymentParticipant = [

// Add participant payment
$participantPaymentParams = [
'participant_id' => $participants[0]->id,
'contribution_id' => $contribution->id,
];
civicrm_api3('ParticipantPayment', 'create', $participantPaymentParams);

CRM_Event_BAO_ParticipantPayment::create($paymentParticipant);
$this->_contactIds[] = $this->_contactId;
}
else {
Expand Down Expand Up @@ -1472,13 +1473,14 @@ public function submit($params) {
}
}

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

Expand Down
9 changes: 6 additions & 3 deletions CRM/Event/Form/Registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ public static function initEventFee(&$form, $eventID) {
*
* @param int $contactID
* @param \CRM_Contribute_BAO_Contribution $contribution
*
* @throws \CiviCRM_API3_Exception
*/
public function confirmPostProcess($contactID = NULL, $contribution = NULL) {
// add/update contact information
Expand Down Expand Up @@ -742,11 +744,11 @@ public function confirmPostProcess($contactID = NULL, $contribution = NULL) {
}

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

$this->assign('action', $this->_action);
Expand Down Expand Up @@ -790,6 +792,7 @@ public function confirmPostProcess($contactID = NULL, $contribution = NULL) {
* @param int $contactID
*
* @return \CRM_Event_BAO_Participant
* @throws \CiviCRM_API3_Exception
*/
public static function addParticipant(&$form, $contactID) {
if (empty($form->_params)) {
Expand Down

0 comments on commit 3bb78d8

Please sign in to comment.