15

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?

6 Answers 6

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.

2
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

1
  • Unfortunately, the extension doesn't seem to offer import of MembershipPayment, the entity that links membership and contribution entries
    – sleidig
    Commented May 20, 2015 at 8:15
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.

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.

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

2
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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.