I am trying to use the BrainTree webhooks for subscription transactions but have been unable to get my page to verify.
From BrainTree: https://www.braintreepayments.com/docs/php/webhooks/destination_verification
When you attempt to add the destination, our servers will make a GET request to the provided URL with a query param named bt_challenge. This query param should be passed to the verify method. The result of calling this method should be returned as the body of the response.
Braintree_WebhookNotification::verify(bt_challenge_param);
First, I tried in NodeJS (as our transactions are successfully done this way):
//WEBHOOK GET PROCESS FOR BRAINTREE SUBSCRIPTION
app.get('/getwebhook', function(req, res){
var bt_challenge_param = req.param('bt_challenge_param', null);
var jsObj = new Object();
jsObj.response = gateway.webhookNotification.verify(bt_challenge_param);
res.json(JSON.stringify(jsObj));
});
where my PHP page communicated with the NodeJS process and puts the result in the body. Once this failed verification, I wrote a test page directly in PHP:
<?php
require_once 'lib/Braintree.php';
Braintree_Configuration::environment('production');
Braintree_Configuration::merchantId('mymid');
Braintree_Configuration::publicKey('mypubkey');
Braintree_Configuration::privateKey('myprodkey');
$bt_challenge = "";
if(isset($_GET['bt_challenge']))
{
$bt_challenge = $_GET['bt_challenge'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Webhooks</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0" />
</head>
<body>
<?php
if(isset($bt_challenge) && $bt_challenge != ""){
echo Braintree_WebhookNotification::verify($bt_challenge);
}
?>
</body>
</html>
However, this too failed verification. Not sure what is wrong as there is no test for verification or any indication of what is wrong. I tried contacting BrainTree support but with no response back.