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 after Paypal Payment
Pages: [1]

Author Topic: Hook after Paypal Payment  (Read 1346 times)

Franco

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.6.12
  • PHP version: 5.4.16
Hook after Paypal Payment
November 19, 2013, 07:36:31 am
Hi,

I know there are a bunch of posts out there about this, specially about using hook_civicrm_postProcess but I couldn't get that to work.

Goal:
Basically I need to change the membership end date after a successful payment.
(ie. if paid in NOV or DEC add a year and end next year on DEC 31), otherwise(before NOV) leave it to end on DEC 31)

Additional Info:
BaseIPN uses  'end_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('end_date', $dates), $format),
to set the date. but this just overwrites any changes I make before.
I tried passing in a $_Session variable from my module into BaseIPN but that didn't work either.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Hook after Paypal Payment
November 19, 2013, 08:30:50 am

1. i'm assuming u r using paypal ipn and hence the postProcess hook does not work

2. can u add code in the _post hook of the membership object. So u can modify the end date there?

in general, hooks are fairly low level and making high level changes are not trivial at times

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Franco

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.6.12
  • PHP version: 5.4.16
Re: Hook after Paypal Payment
November 19, 2013, 08:41:38 am
Thanks for the quick reply!

1. Yea thats definatly why

2. Not sure what exactly you mean, could you please be a bit more specific.

Another approach was to modify the BaseIPN file itself.. but im not sure how exactly to debug thatm since the normal die or vardumps don't show anything after the payment.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Hook after Paypal Payment
November 19, 2013, 11:06:42 am
Check

http://wiki.civicrm.org/confluence/display/CRMDOC/Hook+Reference

The postProcess hook is a form hook. The pre & post hooks are DB hooks - called before & after the membership is saved
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

Franco

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.6.12
  • PHP version: 5.4.16
Re: Hook after Paypal Payment
November 19, 2013, 12:21:34 pm
I used the pre hook before but that only gets called before it goes to paypal.
There is no call to this hook after the payment has been successfully received.


Also it seems if I change the end date in the _pre hook then the BaseIPN file changed the date again.
I tried with _post and it works the same way.

Here inside BaseIPN:
Code: [Select]
$formatedParams = array('status_id' => CRM_Utils_Array::value('id', $calcStatus, 2),
              'join_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('join_date', $dates), $format),
              'start_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('start_date', $dates), $format),
              'end_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('end_date', $dates), $format),
            );

Getting rid of the last line in this array solves the problem but again I would want the date to be changed only after payment has been received.  So this would not work.

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Hook after Paypal Payment
November 23, 2013, 08:26:44 pm
did you see if this hook will work for you?
http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterPaymentProcessorParams
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Franco

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.6.12
  • PHP version: 5.4.16
Re: Hook after Paypal Payment
November 25, 2013, 06:28:26 am
Decided to just modify core using a custom php directory before I found out about,

hook_civicrm_alterPaymentProcessorParams( $paymentObj,&$rawParams, &$cookedParams );

Will try that again in the next phase of our project, and see if I have any luck.
Thanks for the reply though!

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Hook after Paypal Payment
November 25, 2013, 10:52:37 am
If the membership post hook is not being called in this work flow then that should really be fixed in core
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

amitbhoria

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4
  • CMS version: 3
  • MySQL version: 5
  • PHP version: 5
Re: Hook after Paypal Payment
August 12, 2014, 04:17:38 am
if the hook is not working after the payment to change the join,start and end dates of membership then you should make a change in contribution BAO file, well it worked for me ...   8)   ;)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Hook after Paypal Payment

This forum was archived on 2017-11-26.