Sensible location for IPN Callback script

I’m working on a plugin which will involve accepting PayPal Instant Payment Notifications. IPNs are a web-hook which gets called when a payment is processed. Currently I have a script to handle the IPNs within the plugin e.g.

http://mywordpressinstall.com/wp-content/plugins/paypalplugin/IPNHandler.php

Read More

I then paste this URL into the PayPal developer settings area.

I’d like to use a more customizable location for the IPN handler (with a friendlier URL).

I was thinking maybe a shortcode could be used to give ‘handler’ functionality to any page it’s inserted in. Is this a sensible idea? Does anyone have any suggestion on how I can make the URL of the handler shorter?

Thanks!

Related posts

Leave a Reply

1 comment

  1. You can hook to the init action and then check for the query variable, you can use the PayPal provided query var or you can use your own custom query var.

    I will give you example of your own custom query var i.e MYIPN_LISTENER

    The Code:

    function wpse58656_paypal_ipn_listener() {
        // check for your custom query var
        // If you are paranoid you can also check the value of the var
        if ( ! isset( $_GET['MYIPN_LISTENER'] ) ) {
            // if query var is not present just return
            return;
        }
    
        // do the processsing here
    
        // don't forget to exit when you are done
        exit;
    }
    add_action( 'init', 'wpse58656_paypal_ipn_listener' );
    

    Now you can use any URL but it should have MYIPN_LISTENER as a query var e.g: http://mywordpressinstall.com/?MYIPN_LISTENER=1