使用 PHP 获取 Braintree 客户端令牌?

Getting Braintree client token using PHP?

我按照 Braintree 的说明使用 this page 创建客户端令牌。

我创建了一个沙盒帐户。然后,我下载了 PHP 库。下载的文件为 braintree-php-2.37.0.tgz,我将其解压缩。

然后,为 PHP 开发人员使用 Eclipse 并关注 these directions,我:

完成上述所有操作后,我看到在项目的 PHP Include Path 文件夹中,braintreeBraintree.php 和所有内容一起出现。

然后我继续执行第一组说明,我的 PHP 文件基本上如下所示:

Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('<my_merchant_id>');
Braintree_Configuration::publicKey('<my_public_key>');
Braintree_Configuration::privateKey('<my_private_key>');

$clientToken = Braintree_ClientToken::generate();

但是没有任何反应。似乎代码甚至不会通过 Braintree_Configuration::environment('sandbox');.

我在很多地方看到包含[=36​​=]但我不知道如何写Braintree.php文件的路径。我添加了指向我下载 Braintree 文件夹的实际路径,但这根本没有帮助。而且我也更加困惑,因为我认为 Braintree.php 已经添加为库。

我也在使用 Google App Engine 并将我的 PHP 代码上传到他们的服务器。我不确定这是否是问题的一部分。

编辑:

我将解压缩的文件夹 (braintree-php-2.37.0) 复制到 PHP 文件夹中,这样它也可以上传到 Google App Engine。

然后我将 PHP 代码编辑为:

<?php

require_once('./braintree-php-2.37.0/lib/Braintree.php');

Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('<my_merchant_id>');
Braintree_Configuration::publicKey('<my_public_key>');
Braintree_Configuration::privateKey('<my_private_key>');

$clientToken = Braintree_ClientToken::generate();

?>

代码现在不会通过 require_once('./braintree-php-2.37.0/lib/Braintree.php');

在与 Braintree 的工作人员讨论细节后,我们得出的结论是,目前 Google 使用 PHP 的 App Engine 不能很好地与 Braintree 的设置配合使用.

希望以后能解决这个问题。