Skip to content

Instantly share code, notes, and snippets.

@ideadude
Created June 6, 2018 15:33
Show Gist options
  • Save ideadude/8e05f2429914ca2869319c68cebb50aa to your computer and use it in GitHub Desktop.
Save ideadude/8e05f2429914ca2869319c68cebb50aa to your computer and use it in GitHub Desktop.
Test a PayPal Standard IPN with Paid Memberships Pro
/**
* When you pass /?testipn=1 to a WP URL, load our fake IPN data and process it
* You can find the parameter string for an IPN notification from the IPN History in PayPal.
* Update the parameter string to match the data/orders/etc on your site.
*/
function init_test_ipn() {
if(!empty($_REQUEST['testipn'])) {
parse_str( "transaction_subject=Level 1 at YourSite&payment_date=08:11:17 Jun 06, 2018 PDT&txn_type=subscr_payment&subscr_id=I-725WNH95VPUX&last_name=buyer&residence_country=US&item_name=Level 1 at Your Site&payment_gross=10.00&mc_currency=USD&[email protected]&payment_type=instant&protection_eligibility=Eligible&verify_sign=AXOdEKNaKB34xXs1J9eIeoZ2zZOEAmIExVCQqjTzQT7L1yO6NFySiCY7&payer_status=verified&test_ipn=1&[email protected]&txn_id=04404971C88980238&[email protected]&first_name=test&payer_id=ZPTKKEWFN2F2N&receiver_id=6B3GHP8DY7MTG&item_number=79E46DE577&payment_status=Completed&payment_fee=0.59&mc_fee=0.59&mc_gross=10.00&charset=windows-1252&notify_version=3.9&ipn_track_id=dc576b26ed82f", $_POST );
include_once( PMPRO_DIR . '/services/ipnhandler.php' );
exit;
}
}
add_action( 'init', 'init_test_ipn' );
/**
* Tell PMPro to validate fake PayPal IPN notifications.
*/
add_filter( 'pmpro_ipn_validate' , '__return_true' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment