-
-
Save agustinprosperi/9e5181a8a46cac6a2830 to your computer and use it in GitHub Desktop.
Quick snippet/plugin/dropin to test IPN support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: PayPal Sandbox IPN Tester | |
* Description: Pings the IPN endpoint to see if your server can connect. Just head to <a href="/?ipn-test=1">yoursite.com/?ipn-test=1</a> whilst logged in as admin. | |
* Version: 1.0.0 | |
* Author: WooThemes | |
* Requires at least: 4.1 | |
* Tested up to: 4.3 | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
add_action( 'wp_loaded', 'paypal_sandbox_ipn_tester' ); | |
function paypal_sandbox_ipn_tester() { | |
if ( ! empty( $_GET['ipn-test'] ) && current_user_can( 'manage_options' ) ) { | |
$response = wp_safe_remote_post( 'https://www.sandbox.paypal.com/cgi-bin/webscr', array( | |
'body' => array( | |
'test_ipn' => 1, | |
'cmd' => '_notify-validate' | |
) | |
) ); | |
if ( ! is_wp_error( $response ) ) { | |
wp_die( 'SUCCESS' ); | |
} else { | |
wp_die( 'FAIL - ' . $response->get_error_message() ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment