Last active
March 5, 2021 16:37
-
-
Save ideadude/bbfc493fbb242ec28b8fb8543c9a4c46 to your computer and use it in GitHub Desktop.
Testing the Braintree Webhook with PMPro v2.0+
This file contains hidden or 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 | |
/** | |
* Add this function into a customizations plugin | |
* and then visit /?test_braintree_webhook from a browser. | |
*/ | |
function init_test_braintree_webhook() { | |
if(!empty($_REQUEST['test_braintree_webhook'])) { | |
define('PMPRO_BRAINTREE_WEBHOOK_DEBUG', true); | |
$gateway = new PMProGateway_braintree(); | |
$kind = \Braintree\WebhookNotification::SUBSCRIPTION_CHARGED_SUCCESSFULLY; | |
$subscription_transaction_id = 'arealsubidfromyourorderstotest'; //change this | |
$sample_notification = \Braintree\WebhookTesting::sampleNotification($kind, $subscription_transaction_id); | |
$_POST['bt_payload'] = $sample_notification['bt_payload']; | |
$_POST['bt_signature'] = $sample_notification['bt_signature']; | |
$_REQUEST['bt_payload'] = $sample_notification['bt_payload']; | |
$_REQUEST['bt_signature'] = $sample_notification['bt_signature']; | |
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