Php 如何处理BrainTree中的Webhook
我正在尝试使用BrainTree Webhook进行订阅交易,但无法让我的页面进行验证 来自BrainTree: 当您尝试添加目的地时,我们的服务器将使用名为bt_challenge的查询参数向提供的URL发出GET请求。此查询参数应传递给verify方法。调用此方法的结果应作为响应体返回Php 如何处理BrainTree中的Webhook,php,webhooks,braintree,Php,Webhooks,Braintree,我正在尝试使用BrainTree Webhook进行订阅交易,但无法让我的页面进行验证 来自BrainTree: 当您尝试添加目的地时,我们的服务器将使用名为bt_challenge的查询参数向提供的URL发出GET请求。此查询参数应传递给verify方法。调用此方法的结果应作为响应体返回 Braintree_WebhookNotification::verify(bt_challenge_param); 首先,我尝试了NodeJS(因为我们的事务是通过这种方式成功完成的): 其中,我的PHP
Braintree_WebhookNotification::verify(bt_challenge_param);
首先,我尝试了NodeJS(因为我们的事务是通过这种方式成功完成的):
其中,我的PHP页面与NodeJS进程通信,并将结果放入正文中。验证失败后,我直接用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>
网钩
然而,这也未能通过验证。不确定什么是错误的,因为没有验证测试或任何错误指示。我尝试联系BrainTree支持部门,但没有回复。您需要返回测试结果
Braintree_WebhookNotification::verify($bt_challenge);
作为响应的主体,而不是作为响应主体的HTML文档的主体。换句话说,您的整个文件应该类似于:
<?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'];
}
if(isset($bt_challenge) && $bt_challenge != ""){
echo Braintree_WebhookNotification::verify($bt_challenge);
}
?>
如果您还有任何问题,请随时联系
披露:我在Braintree工作。您需要返回
Braintree_WebhookNotification::verify($bt_challenge);
作为响应的主体,而不是作为响应主体的HTML文档的主体。换句话说,您的整个文件应该类似于:
<?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'];
}
if(isset($bt_challenge) && $bt_challenge != ""){
echo Braintree_WebhookNotification::verify($bt_challenge);
}
?>
如果您还有任何问题,请随时联系
披露:我在Braintree工作