Answers.Body: <p>This is doable using the API, and I've accomplished it using Pentaho Kettle.  It has a CiviCRM Input and CiviCRM Output step, which use the REST API.  You're right to be concerned about the SQL-based approach, since there's been discussion of deprecating that table in favor of a line item-based approach to connecting contributions and memberships.</p>
  
  <p>If you use Kettle, you can see my example code here: <a href="https://github.com/PalanteJon/aceware_civicrm_kettle/">https://github.com/PalanteJon/aceware_civicrm_kettle/</a></p>
  
  <p>If you decide to go with the CSV CLI tool, you'll run into trouble, because your output won't contain the ID of the created memberships and payments to create the MembershipPayment record.  So you can either a) use API chaining, or b) do what I did in Kettle, parse the JSON that the API outputs and use that to create your MembershipPayment record.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-16T16:19:07.623Z
Answers.Text: Can you elaborate how to use this. Should I have to download this Pentaho kettle separately ?
Answers.UserDisplayName: Parthibaraj Rajasekar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-16T16:38:29.230Z
Answers.Text: whether this Pentaho kettle solution is simpler or your other solution you have discussed here is simpler to implement?  @Jon-G
   https://civicrm.stackexchange.com/questions/15713/bulk-import-of-membership-dues
Answers.UserDisplayName: Parthibaraj Rajasekar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-24T15:50:04.673Z
Answers.LastActivityDate: 2015-03-24T15:50:04.673Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>I've not used them but have happened on this previously, I believe it's a GUI for the API which allows importing into any entity. Would likely still be a two stage process though, as you'd need the IDs from the first pass</p>
  
  <p><a href="https://civicrm.org/blogs/stoob/csv-api-import" rel="nofollow">https://civicrm.org/blogs/stoob/csv-api-import</a></p>
  
  <p><a href="https://civicrm.org/extensions/api-csv-import-gui" rel="nofollow">https://civicrm.org/extensions/api-csv-import-gui</a> </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-20T08:15:24.803Z
Answers.Text: Unfortunately, the extension doesn't seem to offer import of MembershipPayment, the entity that links membership and contribution entries
Answers.UserDisplayName: sleidig
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-24T16:48:49.813Z
Answers.LastActivityDate: 2015-03-24T16:48:49.813Z
Answers.UserDisplayName: Owen B
Answers.Body: <p>We commissioned a developer to implement a fairly complex migration extension for a project a while back. The whole thing is very much coupled to our system however you might be able to glean something from <a href="https://github.com/JMAConsulting/biz.jmaconsulting.amga/tree/master/api/v3/Job" rel="nofollow">their repo</a>.</p>
  
  <p>They didn't handle payments in this migration, we actually added that after the fact. In our case, we were only concerned with importing payments for event registrations which wound up being a little more complex than just creating a <code>participant</code>, <code>contribution</code>, and <code>participant_payment</code> record. Of course, we were also trying to achieve partial payments in the same process. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-24T15:58:46.373Z
Answers.LastActivityDate: 2015-03-24T15:58:46.373Z
Answers.UserDisplayName: EranSch
Answers.Body: <p>Carlos Capote for Amnesty International Spain has been doing work to facilitate imports and exports using Pentaho Kettle. See <a href="https://civicrm.org/blogs/capo/new-tool-civicrm-data-integration" rel="nofollow">https://civicrm.org/blogs/capo/new-tool-civicrm-data-integration</a> for background and various improvements being done in Fall 2014 (<a href="http://wiki.civicrm.org/confluence/display/CRM/Civi+Data+Integration+v1.2" rel="nofollow">http://wiki.civicrm.org/confluence/display/CRM/Civi+Data+Integration+v1.2</a>). </p>
  
  <p>Code is available at <a href="https://github.com/amnesty/civicrm-data-integration" rel="nofollow">https://github.com/amnesty/civicrm-data-integration</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-31T20:18:08.797Z
Answers.Text: UPDATE:  The bug I mentioned in the comment above has been fixed in the upstream (amnesty) fork - but I don't think it's been pushed to the Kettle Marketplace yet.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-05T20:45:22.077Z
Answers.Text: Note that the version in that repo (and in the Kettle Marketplace) has a nasty bug (https://github.com/amnesty/civicrm-data-integration/issues/21) that's likely to bite you if you do membership/contribution imports.  Until my fix is merged, consider using my fork: https://github.com/PalanteJon/civicrm-data-integration
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-02T23:50:47.460Z
Answers.LastActivityDate: 2015-04-02T23:50:47.460Z
Answers.UserDisplayName: Joe Murray
Answers.Body: <p>If you use Eileen's <a href="https://github.com/eileenmcnaughton/civimigrate" rel="nofollow">https://github.com/eileenmcnaughton/civimigrate</a> then it's not too hard - an import that references the membership import and contribution import and inserts membership payments would be relatively straightforward. This solution requires Drupal, though only during the migration process, you could still use this for a civicrm install for WordPress or Joomla by detaching it and moving it after it's been populated.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-25T20:42:45.743Z
Answers.LastActivityDate: 2015-05-25T20:42:45.743Z
Answers.UserDisplayName: Alan Dixon
Answers.Body: <p>If found this on the old forum</p>
  
  <p><a href="https://forum.civicrm.org/index.php?topic=19322.0" rel="nofollow">https://forum.civicrm.org/index.php?topic=19322.0</a></p>
  
  <p>Where there is some PHP code.</p>
  
  <p>I haven't tried it yet, I was wondering if this approach is still valid.  If I use it and get it to work I will revert back here.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-15T08:51:40.217Z
Answers.LastActivityDate: 2016-09-15T08:51:40.217Z
Answers.UserDisplayName: Alan Fuller
Body: <p>I have a load of Memberships to import. Each has a linked Contribution.</p>
  
  <p>While I can import Memberships and Contributions separately, I cannot find a way to import the two together - in other words there does not seem to be an import routine in any version of CiviCRM which can create an entry in the member_payment table.</p>
  
  <p>In the past I have done this through SQL, which is a bit fragile as a solution. I have been thinking of an API-based approach. But it seems strange if this has not come up before. I haven't even seen any code for this. Is there something out there which I am missing?</p>
  
Tags: <civimember><api><contributions><import><sql>
Title: What's the best way to import memberships and their associated contributions?
ThreadText: # What's the best way to import memberships and their associated contributions?
  
  (Asked by: username_0 on 2015-03-24)
  
  I have a load of Memberships to import. Each has a linked Contribution.
  
  While I can import Memberships and Contributions separately, I cannot find a way to import the two together - in other words there does not seem to be an import routine in any version of CiviCRM which can create an entry in the member\_payment table.
  
  In the past I have done this through SQL, which is a bit fragile as a solution. I have been thinking of an API-based approach. But it seems strange if this has not come up before. I haven't even seen any code for this. Is there something out there which I am missing?
  
  **Tags:** civimember, api, contributions, import, sql
  
  
  ---
  
  ## 6 answers
  
  ### Answer by username_1 on 2015-03-24. Score: 8
  
  This is doable using the API, and I've accomplished it using Pentaho Kettle. It has a CiviCRM Input and CiviCRM Output step, which use the REST API. You're right to be concerned about the SQL-based approach, since there's been discussion of deprecating that table in favor of a line item-based approach to connecting contributions and memberships.
  
  If you use Kettle, you can see my example code here: <https://github.com/PalanteJon/aceware_civicrm_kettle/>
  
  If you decide to go with the CSV CLI tool, you'll run into trouble, because your output won't contain the ID of the created memberships and payments to create the MembershipPayment record. So you can either a) use API chaining, or b) do what I did in Kettle, parse the JSON that the API outputs and use that to create your MembershipPayment record.
  
  > **Comments:**
  > **username_2**: Can you elaborate how to use this. Should I have to download this Pentaho kettle separately ?  
  > **username_2**: whether this Pentaho kettle solution is simpler or your other solution you have discussed here is simpler to implement?  @Jon-G  https://civicrm.stackexchange.com/questions/15713/bulk-import-of-membership-dues  
  
  ---
  
  ### Answer by username_3 on 2015-03-24. Score: 3
  
  I've not used them but have happened on this previously, I believe it's a GUI for the API which allows importing into any entity. Would likely still be a two stage process though, as you'd need the IDs from the first pass
  
  <https://civicrm.org/blogs/stoob/csv-api-import>
  
  <https://civicrm.org/extensions/api-csv-import-gui>
  
  > **Comments:**
  > **username_4**: Unfortunately, the extension doesn't seem to offer import of MembershipPayment, the entity that links membership and contribution entries  
  
  ---
  
  ### Answer by username_5 on 2015-03-24. Score: 2
  
  We commissioned a developer to implement a fairly complex migration extension for a project a while back. The whole thing is very much coupled to our system however you might be able to glean something from [their repo](https://github.com/JMAConsulting/biz.jmaconsulting.amga/tree/master/api/v3/Job).
  
  They didn't handle payments in this migration, we actually added that after the fact. In our case, we were only concerned with importing payments for event registrations which wound up being a little more complex than just creating a `participant`, `contribution`, and `participant_payment` record. Of course, we were also trying to achieve partial payments in the same process.
  
  
  ---
  
  ### Answer by username_6 on 2015-04-02. Score: 2
  
  Carlos Capote for Amnesty International Spain has been doing work to facilitate imports and exports using Pentaho Kettle. See <https://civicrm.org/blogs/capo/new-tool-civicrm-data-integration> for background and various improvements being done in Fall 2014 (<http://wiki.civicrm.org/confluence/display/CRM/Civi+Data+Integration+v1.2>).
  
  Code is available at <https://github.com/amnesty/civicrm-data-integration>
  
  > **Comments:**
  > **username_1**: Note that the version in that repo (and in the Kettle Marketplace) has a nasty bug (https://github.com/amnesty/civicrm-data-integration/issues/21) that's likely to bite you if you do membership/contribution imports.  Until my fix is merged, consider using my fork: https://github.com/PalanteJon/civicrm-data-integration  
  > **username_1**: UPDATE:  The bug I mentioned in the comment above has been fixed in the upstream (amnesty) fork - but I don't think it's been pushed to the Kettle Marketplace yet.  
  
  ---
  
  ### Answer by username_7 on 2015-05-25. Score: 1
  
  If you use Eileen's <https://github.com/eileenmcnaughton/civimigrate> then it's not too hard - an import that references the membership import and contribution import and inserts membership payments would be relatively straightforward. This solution requires Drupal, though only during the migration process, you could still use this for a civicrm install for WordPress or Joomla by detaching it and moving it after it's been populated.
  
  
  ---
  
  ### Answer by username_8 on 2016-09-15. Score: 1
  
  If found this on the old forum
  
  <https://forum.civicrm.org/index.php?topic=19322.0>
  
  Where there is some PHP code.
  
  I haven't tried it yet, I was wondering if this approach is still valid. If I use it and get it to work I will revert back here.
  
  
  ---
  
  