Answers.Body: <p>The advice to use Order API is still sound and should be followed. As of this post it has not yet been ported to APIv4 so you'll have to use v3 until that work is complete. Progress on the port can be tracked at <a href="https://lab.civicrm.org/dev/core/-/issues/4367" rel="nofollow noreferrer">GitLab: Apiv4 Order api</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-06T13:36:06.367Z
Answers.LastActivityDate: 2023-09-06T13:36:06.367Z
Answers.UserDisplayName: Coleman
Body: <p>I am using a script that creates a MembershipPayment to connect an existing Membership to an existing Contribution (bugfix for CiviSepa).  This script produces the following error:</p>
  <pre><code>Deprecated: Not having valid line items for membership payments is invalid. Caller: CRM_Contribute_BAO_Contribution::updateMembershipBasedOnCompletionOfContribution
  </code></pre>
  <p>In order to fix this, I thought I should switch to create the MembershipPayment via Order API instead of using</p>
  <pre><code>civicrm_api3('MembershipPayment', 'create', [...]);
  </code></pre>
  <p>In the <a href="https://docs.civicrm.org/dev/en/latest/financial/orderAPI/#membership-dates-statuses-and-renewals" rel="nofollow noreferrer">CiviCRM documentation</a>, it is clearly recommended to use the Order API for managing Contributions, Memberships etc.
  At the same time, <a href="https://docs.civicrm.org/dev/en/latest/api/" rel="nofollow noreferrer">it is also recommended</a> to use APIv4 instead of APIv3 for all future projects: &quot;APIv3 is now minimally maintained with no new features and regression bug-fixes only. Your code can use a combination of v3 and v4 API calls, but v4 is recommended for all new projects.&quot;</p>
  <p>The problem is that the Order API doesn't even exist in API v4. I cannot choose the entity Order from the drop down menue in APIv4 Explorer.</p>
  <p>Where does this contradiction come from? Which advice should I follow?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-09-06T13:32:45.550Z
Comments.Text: See https://lab.civicrm.org/dev/core/-/issues/4367
Comments.UserDisplayName: Demerit
Tags: <civimember><api><apiv4>
Title: Use Order API or use APIv4?
ThreadText: # Use Order API or use APIv4?
  
  (Asked by: username_0 on 2023-09-06)
  
  I am using a script that creates a MembershipPayment to connect an existing Membership to an existing Contribution (bugfix for CiviSepa). This script produces the following error:
  
  ```
  Deprecated: Not having valid line items for membership payments is invalid. Caller: CRM_Contribute_BAO_Contribution::updateMembershipBasedOnCompletionOfContribution
  
  ```
  
  In order to fix this, I thought I should switch to create the MembershipPayment via Order API instead of using
  
  ```
  civicrm_api3('MembershipPayment', 'create', [...]);
  
  ```
  
  In the [CiviCRM documentation](https://docs.civicrm.org/dev/en/latest/financial/orderAPI/#membership-dates-statuses-and-renewals), it is clearly recommended to use the Order API for managing Contributions, Memberships etc.
  At the same time, [it is also recommended](https://docs.civicrm.org/dev/en/latest/api/) to use APIv4 instead of APIv3 for all future projects: "APIv3 is now minimally maintained with no new features and regression bug-fixes only. Your code can use a combination of v3 and v4 API calls, but v4 is recommended for all new projects."
  
  The problem is that the Order API doesn't even exist in API v4. I cannot choose the entity Order from the drop down menue in APIv4 Explorer.
  
  Where does this contradiction come from? Which advice should I follow?
  
  **Tags:** civimember, api, apiv4
  
  > **Comments:**
  > **username_1**: See https://lab.civicrm.org/dev/core/-/issues/4367  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2023-09-06. Score: 2 | Accepted answer
  
  The advice to use Order API is still sound and should be followed. As of this post it has not yet been ported to APIv4 so you'll have to use v3 until that work is complete. Progress on the port can be tracked at [GitLab: Apiv4 Order api](https://lab.civicrm.org/dev/core/-/issues/4367).
  
  
  ---
  
  