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) »
  • hook for contribution success -paypal standard
Pages: [1]

Author Topic: hook for contribution success -paypal standard  (Read 831 times)

usr238496

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 0
  • CiviCRM version: latest
  • CMS version: joomla2.5
  • PHP version: 5 something
hook for contribution success -paypal standard
June 14, 2012, 03:36:19 pm
I've had a look through the available hooks here but cannot see anything that might allow me hook into when paypal standard returns a success payment made.

I know waiting for the user to come back to the site may mean the event is never fired if they do not come back to site after payment made and just close the window. This is no big deal.

Another option would be to hook into when they click the "confirm" button to go to the paypal log in screen. However, I do not want to assume they will make a payment.

For what I need it would be better to miss users who do not come back to the site, than to assume users pay who do not.


Is there an event for what I need, or does the return url have a form name which fires the buildform / postprocess events?
You did not answer the verification questions correctly - sigh

usr238496

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 0
  • CiviCRM version: latest
  • CMS version: joomla2.5
  • PHP version: 5 something
Re: hook for contribution success -paypal standard
June 14, 2012, 03:40:02 pm
In a mumbling my thoughts out loud kind way.

I suppose if there is no payment success hook, the url variable
Code: [Select]
&_qf_ThankYou_display=1

could be detected on a page load and used accordingly, although not so secure
You did not answer the verification questions correctly - sigh

usr238496

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 0
  • CiviCRM version: latest
  • CMS version: joomla2.5
  • PHP version: 5 something
Re: hook for contribution success -paypal standard
June 14, 2012, 03:46:39 pm
Mumble to oneself and the murky waters clear.

Incase anyone finds this post who is also bad at skim reading the documention

Code: [Select]
hook_civicrm_post( $op, $objectName, $objectId, &$objectRef )
$op - operation being performed with CiviCRM object. Can have the following values:
        'view' : The CiviCRM object is going to be displayed
        'create' : The CiviCRM object is created (or contacts are being added to a group)
        'edit' : The CiviCRM object is edited
        'delete' : The CiviCRM object is being deleted (or contacts are being removed from a group)

        'trash': The contact is being moved to trash (Contact objects only)
        'restore': The contact is being restored from trash (Contact objects only)

    $objectName - can have the following values:
        'Individual'
        'Household'
        'Organization'
        'Grant'
        'Group'
        'GroupContact'
        'Relationship'
        'Activity'
        'Contribution'
        'Profile' (while this is not really an object, people have expressed an interest to perform an action when a profile is created/edited)
        'Membership'
        'Participant'
        'UFMatch' (when an object is linked to a CMS user record, at the request of GordonH. A UFMatch object is passed for both the pre and post hooks)
        'Event'
        'EntityTag'
        'Tag'

        PledgePayment
        ContributionRecur
        Pledge
You did not answer the verification questions correctly - sigh

usr238496

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 0
  • CiviCRM version: latest
  • CMS version: joomla2.5
  • PHP version: 5 something
Re: hook for contribution success -paypal standard
June 14, 2012, 07:07:18 pm
Perhaps I jumped the gun on my enthusiasm.

I added some debugging code to the civicrm_post hook, and on an event ticket contribution, I get the following data from the post hook.

Code: [Select]
op: create
obj name: Activity
CRM_Activity_DAO_Activity Object
(
    [id] => 2
    [source_contact_id] => 1
    [source_record_id] => 1
    [activity_type_id] => 5
    [subject] => Event Name - December 20th, 2012  4:28 PM - Attendee - Pending from incomplete transaction
....

Yet when searching for the contributions form the backend, I can see the purchase was successful and access the transaction ids. This makes me think that there is a callback happening between civi and paypal that writes to the db that doesn't get sent to civicrm_post hook.
You did not answer the verification questions correctly - sigh

usr238496

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 0
  • CiviCRM version: latest
  • CMS version: joomla2.5
  • PHP version: 5 something
Re: hook for contribution success -paypal standard
June 14, 2012, 07:31:52 pm
Ok so I have an actual question, rather than talking to myself into solutions :)


From the activity obj above, how can I get the db event object. I had a look at activity type_id, but I do not really understand what it is doing, as from phpmyadmin:

activity_type_id FK to civicrm_option_value.id, that has to be valid, registered activity type.

Ok, so off to civicrm_option_value I go, and row with id=5 has a label "fax". My event isn't a fax machine so I guess I have some fatal misunderstanding here :)

Code: [Select]
CRM_Activity_DAO_Activity Object
(
    [id] => 2
    [source_contact_id] => 1
    [source_record_id] => 1
    [activity_type_id] => 5
    [subject] => Event name - December 20th, 2012  4:28 PM - Attendee - Pending from incomplete transaction
    [activity_date_time] => 20120614185616
    [duration] =>
    [location] =>
    [phone_id] =>
    [phone_number] =>
    [details] =>
    [status_id] => 2
    [priority_id] => 2
    [parent_id] =>
    [is_test] => 0
    [medium_id] =>
    [is_auto] =>
    [relationship_id] =>
    [is_current_revision] =>
    [original_id] =>
    [result] =>
    [is_deleted] =>
    [campaign_id] =>
    [engagement_level] =>
    [weight] =>
    [_DB_DataObject_version] => 1.8.12
    [__table] => civicrm_activity
    [N] => 0
    [_database_dsn] =>
    [_database_dsn_md5] => 8a633d47982y3riuhf57a4
    [_database] => dbname
    [_query] => Array
        (
            [condition] =>
            [group_by] =>
            [order_by] =>
            [having] =>
            [limit_start] =>
            [limit_count] =>
            [data_select] => *
        )

    [_DB_resultid] =>
    [_resultFields] =>
    [_link_loaded] =>
    [_join] =>
    [_lastError] =>
)
You did not answer the verification questions correctly - sigh

usr238496

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 0
  • CiviCRM version: latest
  • CMS version: joomla2.5
  • PHP version: 5 something
Re: hook for contribution success -paypal standard
June 15, 2012, 12:33:20 pm
On further investigation, when on the Event "check the details and then click continue to go pay" screen, when the user clicks continue, the following civicrm_post hooks are fired

create obj -  name: Address
create obj - name: Individual  - CRM_Contact_DAO_Contact Object
create obj - name: Profile
create obj - name: Contribution -  CRM_Contribute_BAO_Contribution Object
create obj - name: Participant -  CRM_Event_BAO_Participant Object
create obj - name: Activity - CRM_Activity_DAO_Activity Object

However, I cannot detect anything happening after the payment has actually been made.
You did not answer the verification questions correctly - sigh

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • hook for contribution success -paypal standard

This forum was archived on 2017-11-26.