• Resolved mifydnu

    (@mifydnu)


    Hello all – I need to be able to automatically take some actions when a successful IPN has been received. Looking into the paypal-ipn code in this plugin I had thought it would be a simple matter to hook to ‘post_updated’ and grab the info I needed. Unfortunately, the data I need i.e. the actual paypal response is included as a string (the output of a print_r(). Ugh. So then I tried hooking ‘updated_meta’ to watch for the keys when called in paypal-ipn.php. But my add_action is not firing. Any suggestions on how to hook to the order completion process? I just can’t manually check the Order page.

    The working add_action code looks like this:

    function hmm_grab_update_hook($post_id,$after,$before) {
     // do stuff
    }
    add_action('post_updated','hmm_grab_update_hook',12,3);

    but $after->post_content is a string rather than an object or even json so other than manually parsing… Not attractive.

    The non-working code looks like:

    function hmm_update_meta_hook($meta_id,$post_id,$meta_key,$meta_value){
     // do stuff (if I ever got called!)
    }
    add_action('updated_post_meta','hmm_update_meta_hook',10,4);

    Could really use some help here!
    Thanks!
    Andy

    • This topic was modified 4 years, 5 months ago by mifydnu.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter mifydnu

    (@mifydnu)

    Some progress that may help others:

    Looks like add_action('added_post_meta','hmm_update_meta_hook',10,4)
    to hook the meta update. Not entirely clear on why but it works. That doesn’t solve my problem as the plugin code that does the meta updates doesn’t provide everything I need.

    In the interim, I’ve just added a call to a routine external to the plugin and am passing $ipn_response. Works great. Entirely inelegant and unsupportable. 🙂 Really need a hook into the actual IPN response. Is that possible with this plugin?

    Plugin Author Noor Alam

    (@naa986)

    @mifydnu, A new action is now triggered after processing the ipn. You can hook into it like this example:

    function my_callback_function($ipn_response) {
        // do stuff
        
    }
    add_action('wp_paypal_ipn_processed', 'my_callback_function');
    

    Please make sure to update the plugin before using it.

    Thread Starter mifydnu

    (@mifydnu)

    Sweet!!! I will try it ASAP and update this thread with results. What a great response to a user request. I was getting very nervous about all the code I was writing on the back of a hack. 🙂

    Thread Starter mifydnu

    (@mifydnu)

    Has the update been published? I’ve 1.1.3 installed but I don’t see any update published or pending yet. Thanks

    Thread Starter mifydnu

    (@mifydnu)

    This one was resolved with the 1.1.6 update as well (maybe in 1.1.4 or 1.1.5 but I jumped from 1.1.3 to 1.1.6).

    I really like these lightweight plugins that provided a straight-forward API. Sometimes that’s all you need.

    Thanks again!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hooking into PayPal-IPN processing’ is closed to new replies.