Handle participant payment create in line item
authorEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 18 Jun 2021 07:02:17 +0000 (19:02 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 7 Jul 2021 03:28:55 +0000 (15:28 +1200)
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
api/v3/Order.php

index f4271716aa193f6ddd1364d974ff9a9128d63472..c2c707f7b0c46e6d9ce0cd51a98d54fdcbfd17c8 100644 (file)
@@ -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
index cf0e8ee50ebe9c6f7c22a9155ccd554437da0681..b14818e06ec71e3416b203d24b21cfd67d79e8c4 100644 (file)
@@ -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');