From: Eileen McNaughton Date: Fri, 18 Jun 2021 07:02:17 +0000 (+1200) Subject: Handle participant payment create in line item X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b87dd88bf6e671788fac4c72dd1b442dcdbb482e;p=civicrm-core.git Handle participant payment create in line item Remove participant payment create from order api This is now done in the line item create & we went through to 'prove' that it works with extra validation --- diff --git a/CRM/Price/BAO/LineItem.php b/CRM/Price/BAO/LineItem.php index f4271716aa..c2c707f7b0 100644 --- a/CRM/Price/BAO/LineItem.php +++ b/CRM/Price/BAO/LineItem.php @@ -72,6 +72,15 @@ class CRM_Price_BAO_LineItem extends CRM_Price_DAO_LineItem { civicrm_api3('MembershipPayment', 'create', $membershipPaymentParams); } } + if ($lineItemBAO->entity_table === 'civicrm_participant' && $lineItemBAO->contribution_id && $lineItemBAO->entity_id) { + $participantPaymentParams = [ + 'participant_id' => $lineItemBAO->entity_id, + 'contribution_id' => $lineItemBAO->contribution_id, + ]; + if (!civicrm_api3('ParticipantPayment', 'getcount', $participantPaymentParams)) { + civicrm_api3('ParticipantPayment', 'create', $participantPaymentParams); + } + } if ($id) { // CRM-21281: Restore entity reference in case the post hook needs it diff --git a/api/v3/Order.php b/api/v3/Order.php index cf0e8ee50e..b14818e06e 100644 --- a/api/v3/Order.php +++ b/api/v3/Order.php @@ -160,10 +160,6 @@ function civicrm_api3_order_create(array $params): array { CRM_Core_Error::deprecatedWarning('This should be unreachable & tests show it is never tested.'); civicrm_api3('PledgePayment', 'create', $paymentParams); } - if ($entity === 'participant') { - civicrm_api3('ParticipantPayment', 'create', $paymentParams); - } - } } return civicrm_api3_create_success($contribution['values'] ?? [], $params, 'Order', 'create');