PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Equivalent hook for notification API url

s2Member Plugin. A Membership plugin for WordPress®.

Equivalent hook for notification API url

Postby hoststreamsell » December 20th, 2011, 5:53 pm

Hi, I am trying to figure out which hook gets called when a buy now paypal payment is made. I can get the notification API to call a url but would like to be able to have more control over this by way of a hook.

I have tried the following but it doesn't seem to fire.
add_action('ws_plugin__s2member_after_paypal_notify', 'my_method');

I have got other hooks to work once the user returns back to the website from paypal, but I would like to use the hook which fires when the payment is made just like the notification API url.

Thanks,
Gavin
User avatar
hoststreamsell
Registered User
Registered User
 
Posts: 6
Joined: December 20, 2011

Re: Equivalent hook for notification API url

Postby hoststreamsell » December 22nd, 2011, 8:39 am

Anybody? I have tried to find this myself but not having any luck
User avatar
hoststreamsell
Registered User
Registered User
 
Posts: 6
Joined: December 20, 2011

Re: Equivalent hook for notification API url

Postby Raam Dev » December 22nd, 2011, 5:07 pm

Hello,

If the payment is being made on PayPal's website, there won't be any way to hook into that from s2Member (since the user isn't on your site anymore, they're on PayPal's website). You might want to try hooking into the checkout process itself instead.

See the list of s2Member PayPal hooks and try searching for "checkout".
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011

Re: Equivalent hook for notification API url

Postby hoststreamsell » December 22nd, 2011, 5:25 pm

Hi Raam Dev, first off thanks for the reply. The payment is indeed being made on paypal's site, but the notification API url gets triggered as soon as the payment is made, even though it is on the paypal site. So I am thinking there must be some part of the code that is being triggered even before the user comes back to the site from paypal?

I'll look at the hooks again as you suggest and see if I can find something.
User avatar
hoststreamsell
Registered User
Registered User
 
Posts: 6
Joined: December 20, 2011

Re: Equivalent hook for notification API url

Postby Raam Dev » December 23rd, 2011, 2:00 pm

Ah yes, the PayPal does send the IPN notification upon payment, but I'm not sure if there's a way to hook into that. I just looked through the s2Member Codex and didn't find anything related to IPN messages.

Did you find anything in the PayPal Hooks that might work for your scenario?
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011

Re: Equivalent hook for notification API url

Postby Jason Caldwell » December 26th, 2011, 4:29 pm

Thanks for the heads up on this thread.

There are about 200 Hooks/Filters specifically related to IPNs and Payment Data Transfer, making it very possible to filter and/or hook into s2Member's processing routines in all sorts of creative ways.
See: viewtopic.php?f=40&t=12778&src_doc_v=111220

This is one of the most popular Hooks, and might do nicely in your scenario:
Code: Select all
ws_plugin__s2member_during_paypal_notify_during_subscr_signup_wo_update_vars
See: viewtopic.php?f=40&t=14521&src_doc_v=111220#src_doc_line_454

There is also this Hook, which deals with modifications, instead of initial purchases:
Code: Select all
ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars
See: viewtopic.php?f=40&t=14521&src_doc_v=111220#src_doc_line_296
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Equivalent hook for notification API url

Postby hoststreamsell » January 4th, 2012, 9:25 am

Hi Jason, only getting a chance to try this out now after the holidays. After a quick test it looks to do what I want. Thanks for the information!

Actually my mistake, it is still only the notification url that is being called. This is what I am doing in my plugin...

Code: Select all
add_action('ws_plugin__s2member_during_paypal_notify_during_subscr_signup_wo_update_vars', 'do_paypal_ccap');

function do_paypal_ccap($vars = array()){
        $fh = fopen('/home/.sites/_default/logs/s3_log.txt', 'a');
        fwrite($fh, "do_paypal_ccap\n");
        $item_number = $vars["paypal"]["item_number"];
        $user_id = $vars["user_id"];
        fwrite($fh, "3 USER:".$user_id." ITEM:".$item_number."\n");
}

User avatar
hoststreamsell
Registered User
Registered User
 
Posts: 6
Joined: December 20, 2011

Re: Equivalent hook for notification API url

Postby hoststreamsell » January 4th, 2012, 5:10 pm

Ok, I figured out why it's not working. I am using buy now buttons but the hooks you provided are for subscription buttons (I should have noticed sooner given the action names). I have got it working if I use a subscription button for a member level, but I also want to be able to use buy now buttons for custom capabilities. Is there an equivalent hook for buy now purchases?

Thanks!
User avatar
hoststreamsell
Registered User
Registered User
 
Posts: 6
Joined: December 20, 2011

Re: Equivalent hook for notification API url

Postby Raam Dev » January 4th, 2012, 8:33 pm

Have you tried searching the Package s2Member\PayPal ( 197 Hooks/Filters ) list for "ws_plugin__s2member_during_paypal_notify_during_"? Will any of those hooks work for you?

Perhaps this one:
Code: Select all
ws_plugin__s2member_during_paypal_notify_during_before_new_ccaps


Or this one:
Code: Select all
ws_plugin__s2member_during_paypal_notify_during_new_ccaps
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011

Re: Equivalent hook for notification API url

Postby hoststreamsell » January 5th, 2012, 4:02 am

Thanks, that works. Both this

Code: Select all
ws_plugin__s2member_during_paypal_notify_before_new_ccaps


and this

Code: Select all
ws_plugin__s2member_during_paypal_notify_during_before_new_ccaps


seem to get called once the pay button is clicked. Awesome!

I am not sure why you would use one rather than the other? Is it maybe possible with the later to perform some logic within my system to check whether I want the purchase to proceed or not, and force the paypal payment to fail if there is some internal condition in my system not met? Just curious as to what else is possible...
User avatar
hoststreamsell
Registered User
Registered User
 
Posts: 6
Joined: December 20, 2011

Re: Equivalent hook for notification API url

Postby Raam Dev » January 5th, 2012, 5:26 pm

I'm not entirely sure. That would require digging into the code here (during_before_new_ccaps) and here (before_new_ccaps).

It looks like during_before_new_ccaps gets called before the user is added or ccaps are updated.
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 1 guest

cron