CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • CiviCRM API v3 - Implementing ContributionPage CRUD
Pages: [1] 2

Author Topic: CiviCRM API v3 - Implementing ContributionPage CRUD  (Read 2556 times)

geekdenz

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
    • Geek.De.NZ
  • CiviCRM version: 4.2 (development)
  • CMS version: Drupal 7.12
  • MySQL version: 5
  • PHP version: 5
CiviCRM API v3 - Implementing ContributionPage CRUD
July 14, 2012, 06:21:02 pm
Just to let people know:

I'm giving implementing this part of the API a go because I haven't found it anywhere yet and I need it for a client project. Please let me know if you have implemented or are implementing this feature because I do not want to double up efforts.

The good thing about FOSS is that developers can always make sure they're doing something new.
Twitter: @geekdenz

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: CiviCRM API v3 - Implementing ContributionPage CRUD
July 14, 2012, 09:21:27 pm
It hasn't been done - but the standards doc is pretty up to date so start from here

http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: CiviCRM API v3 - Implementing ContributionPage CRUD
July 14, 2012, 09:22:39 pm
And start with the basic_get etc functions if you can - ie I think survey & campaign use them
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

geekdenz

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
    • Geek.De.NZ
  • CiviCRM version: 4.2 (development)
  • CMS version: Drupal 7.12
  • MySQL version: 5
  • PHP version: 5
Re: CiviCRM API v3 - Implementing ContributionPage CRUD
July 14, 2012, 10:40:50 pm
Should I implement it against the latest trunk version or the stable 4.1 version that I'm using?
Twitter: @geekdenz

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: CiviCRM API v3 - Implementing ContributionPage CRUD
July 14, 2012, 10:51:03 pm
Against trunk please - or 4.2 if you are going to be doing it fairly quickly
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

geekdenz

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
    • Geek.De.NZ
  • CiviCRM version: 4.2 (development)
  • CMS version: Drupal 7.12
  • MySQL version: 5
  • PHP version: 5
Re: CiviCRM API v3 - Implementing ContributionPage CRUD
July 15, 2012, 02:49:58 am
OK, doing it against trunk. It seems to be easiest. Just copied the trunk version of the api folder over to my installation, copied ContributionRecur.php to ContributionPage.php and changed the calls from contribution_recur to contribution_page. Didn't even have to think much. Might have to check that everything works but basic get seems to just work. Trunk seems to have a good abstraction and make the API even simpler! Since I'm at it I might ensure that only valid calls can be made. I saw that there is at least one variable variable in there. I guess because it's inside a function there are no major security concerns?

I will probably not need much more of the API, but will keep this thread open for when/if I get to problems.

Patch attached.

Thanks!
Twitter: @geekdenz

geekdenz

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
    • Geek.De.NZ
  • CiviCRM version: 4.2 (development)
  • CMS version: Drupal 7.12
  • MySQL version: 5
  • PHP version: 5
Re: CiviCRM API v3 - Implementing ContributionPage CRUD
July 15, 2012, 02:59:00 am
OK, just for the record. The Create action does not work now. Fixing...
Twitter: @geekdenz

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: CiviCRM API v3 - Implementing ContributionPage CRUD
July 15, 2012, 03:02:33 am
Hi,

The api itself should be fairly easy to write (hopefully) - but please make sure you add a unit test too! Otherwise it has no future proofing

Eileen
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

geekdenz

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
    • Geek.De.NZ
  • CiviCRM version: 4.2 (development)
  • CMS version: Drupal 7.12
  • MySQL version: 5
  • PHP version: 5
Re: CiviCRM API v3 - Implementing ContributionPage CRUD
July 15, 2012, 03:29:59 am
It's been a long time since I wrote my last test cases (at Uni, to be honest), but should really get into the habit anyhow. So, yes, will do.
Twitter: @geekdenz

geekdenz

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
    • Geek.De.NZ
  • CiviCRM version: 4.2 (development)
  • CMS version: Drupal 7.12
  • MySQL version: 5
  • PHP version: 5
Re: CiviCRM API v3 - Implementing ContributionPage CRUD
July 15, 2012, 04:10:50 am
Mh, maybe not as easy as I hoped for. It seems like the CREATE call loops forever now in some weird calling itself way. Debugging gets confusing because the civicrm_api function gets called multiple times over and over. However, when I have the debugger running on it it returns after a bit. If no debugger is attached I get a white page, one of the reasons I'm starting to dislike PHP. Wondering now if the API is not fully compatible with 4.1 and whether I should try the trunk version with possible instabilities or do the "tedious" 4.1 way of doing it. I guess to have it supported down the road doing it in trunk is the only option, however risky for this project.

What do you think? I've used cutting edge stuff before in projects because it usually has features that are new and for our test purpouses it seemed to run better in that case (OpenLayers), but newer is not always better.
Twitter: @geekdenz

geekdenz

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
    • Geek.De.NZ
  • CiviCRM version: 4.2 (development)
  • CMS version: Drupal 7.12
  • MySQL version: 5
  • PHP version: 5
Re: CiviCRM API v3 - Implementing ContributionPage CRUD
July 15, 2012, 04:32:42 am
More weirdness: Now it works fine. Maybe a bug in xdebug or some condition on my machine?

Anyway, that's me for today. Will keep this posted in case there is more.
Twitter: @geekdenz

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: CiviCRM API v3 - Implementing ContributionPage CRUD
July 15, 2012, 02:39:05 pm
Hmm - there is some debug stuff associated with x_debug in the api - which might be causing the loop.

Yes, the API does call itself a few times - mostly it calls the 'getfields' function when checking required fields are set, merging fields, doing validation. We cache the getfields response but it is a bit confusing in debugging - esp if you have x_debug on.

I actually always write the tests while doing any api development & I put the debug in the tests themselves.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

geekdenz

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
    • Geek.De.NZ
  • CiviCRM version: 4.2 (development)
  • CMS version: Drupal 7.12
  • MySQL version: 5
  • PHP version: 5
Re: CiviCRM API v3 - Implementing ContributionPage CRUD
July 17, 2012, 03:58:40 am
I will get the test system up and running here and hopefully will have some test cases written by the end of the week. Doing this outside of business hours, so bear with me.

Regards,
Tim
Twitter: @geekdenz

geekdenz

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
    • Geek.De.NZ
  • CiviCRM version: 4.2 (development)
  • CMS version: Drupal 7.12
  • MySQL version: 5
  • PHP version: 5
Re: CiviCRM API v3 - Implementing ContributionPage CRUD
July 22, 2012, 03:34:59 am
Just to give you a status update:

Finally got unit tests to work on my machine. Output:

Code: [Select]
$ scripts/phpunit -uroot -pPASS -hlocalhost -bcivicrm_tests_dev api_v3_ContactTest
PHPUnit 3.6.10 by Sebastian Bergmann.

.
Installing civicrm_tests_dev database
............................................................

Time: 01:34, Memory: 56.00Mb

OK (61 tests, 157 assertions)

Was not hard but not trivial either.

So, now off to write my own tests for the ContributionPage CRUD extension of the API.
Twitter: @geekdenz

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: CiviCRM API v3 - Implementing ContributionPage CRUD
July 22, 2012, 01:42:43 pm
Cool - have you logged a ticket in JIRA for this yet?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • CiviCRM API v3 - Implementing ContributionPage CRUD

This forum was archived on 2017-11-26.