From b87dd88bf6e671788fac4c72dd1b442dcdbb482e Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 18 Jun 2021 19:02:17 +1200 Subject: [PATCH] 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 --- CRM/Price/BAO/LineItem.php | 9 +++++++++ api/v3/Order.php | 4 ---- 2 files changed, 9 insertions(+), 4 deletions(-) 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'); -- 2.25.1