Skip to content

Instantly share code, notes, and snippets.

@ideadude
Created March 5, 2021 16:36
Show Gist options
  • Save ideadude/cc026d39003b07ca9a81ff1544b676e4 to your computer and use it in GitHub Desktop.
Save ideadude/cc026d39003b07ca9a81ff1544b676e4 to your computer and use it in GitHub Desktop.
Testing the PMPro Braintree using the signature and payload from a webhook log.
<?php
/**
* Add this function into a customizations plugin
* and then visit yoursite.com/wp-admin/?test_braintree_webhook=1 from a browser.
*/
function init_test_braintree_webhook() {
if(!empty($_REQUEST['test_braintree_webhook'])) {
define('PMPRO_BRAINTREE_WEBHOOK_DEBUG', true);
$_POST['bt_signature'] = 'putthesignaturefromthewebhookloghere';
$_POST['bt_payload'] = 'putthepayloadfromthewebhookloghereitsreallylong';
$_REQUEST['bt_signature'] = $_POST['bt_signature'];
$_REQUEST['bt_payload'] = $_POST['bt_payload'];
require_once(PMPRO_DIR . "/services/braintree-webhook.php");
exit;
}
}
add_action('init', 'init_test_braintree_webhook');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment