Skip to content

Instantly share code, notes, and snippets.

@ideadude
Created May 4, 2019 15:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ideadude/baee2307c7024b63ec48fbea50cf5a29 to your computer and use it in GitHub Desktop.
Save ideadude/baee2307c7024b63ec48fbea50cf5a29 to your computer and use it in GitHub Desktop.
Forward PMPro PayPal IPNs to another domain
/**
* Forward PMPro PayPal IPNs to another domain.
* Each domain will process the IPNs. The IPN handlers should be setup to ignore
* messages that aren't for that site. PMPro does this.
* This is useful if you have 2 different sites using the same PayPal account
* and the IPN is setup to go to a PMPro site.
* Add this to a custom plugin on the PMPro site the IPN hits.
* Update the domain/url to the IPN you want to forward to.
* The pmprodev_gateway_debug_setup check makes sure this DOESN'T run if you have the
* PMPro Toolkit plugin enabled, i.e. you are on a staging site.
*/
function my_pmpro_forward_ipn() {
if ( ! function_exists( 'pmprodev_gateway_debug_setup' ) ) {
$fp = wp_remote_post( 'https://yourdomain.com/wp-admin/admin-ajax.php?action=ipnhandler', $_POST );
}
}
add_action('wp_ajax_nopriv_ipnhandler', 'my_pmpro_forward_ipn', 5);
add_action('wp_ajax_ipnhandler', 'my_pmpro_forward_ipn', 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment