1

我有一个包含许多文件夹/子文件夹/文件的应用程序,我似乎无法让 Braintree 正常运行。有什么我只是在这里想念的吗?假设我的网站名称是 DIR。

从braintree文件夹解压的所有文件都在DIR/braintree_payments

然后我的 transaction.php 文件在 DIR/templates/content/listing

表单的所有标签都在 DIR/templates/content/listing/confirm_booking.tpl.php

confirm_booking.tpl.php
                <h1>Braintree Credit Card Transaction Form</h1>
                    <div style="position:relative;">
                      <form action="transaction.php" method="POST" id="braintree-payment-form">
                        <p>
                          <label>Card Number</label>
                          <input type="text" size="20" autocomplete="off" data-encrypted-name="number" />
                        </p>
                        <p>
                          <label>CVV</label>
                          <input type="text" size="4" autocomplete="off" data-encrypted-name="cvv" />
                        </p>
                        <p>
                          <label>Expiration (MM/YYYY)</label>
                          <input type="text" size="2" name="month" /> / <input type="text" size="4" name="year" />
                        </p>
                        <input type="submit" id="submit" />
                      </form>
                    </div>
                    <script type="text/javascript" src="https://js.braintreegateway.com/v1/braintree.js"></script>
                    <script type="text/javascript">
                      var braintree = Braintree.create("awefawef2oIaXiawefawefawefoP1jJ3LNuLchxfeawfawetq34tq34tq34tBtfTk6KnM0Bk3TkofNMM2CG/1ktaBDa+BEbteZjF05e5Jjfwefawfawe4t34434CVxaXNAbgZEn+ECWiZ2rynxtme5goMAhYAS+blBaVlL9+affawef aw/NLhqKmwQL7zuK3GBGiOp3ht9rL3AI1O84o1WpjVeqt8Xgg5MQe4jRTGJAfR3Rv25KPuwRaTqrevyVyRkPekcCIp1HROoZGelQyaSsPzhA0/FApbRu0Vpcx6kUwIDAQAB");
                      braintree.onSubmitEncryptForm('braintree-payment-form');
                    </script>



transaction.php

<?PHP
require_once 'braintree_payments/lib/Braintree.php';

Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('389yhf9gf82gf3');
Braintree_Configuration::publicKey('r3h89h39h833');
Braintree_Configuration::privateKey('my_private_api_key');

$result = Braintree_Transaction::sale(array(
    "amount" => "1000.00",
    "creditCard" => array(
        "number" => $_POST["number"],
        "cvv" => $_POST["cvv"],
        "expirationMonth" => $_POST["month"],
        "expirationYear" => $_POST["year"]
    ),
    "options" => array(
        "submitForSettlement" => true
    )
));

if ($result->success) {
    echo("Success! Transaction ID: " . $result->transaction->id);
} else if ($result->transaction) {
    echo("Error: " . $result->message);
    echo("<br/>");
    echo("Code: " . $result->transaction->processorResponseCode);
} else {
    echo("Validation errors:<br/>");
    foreach (($result->errors->deepAll()) as $error) {
        echo("- " . $error->message . "<br/>");
    }
}

?>
4

1 回答 1

0

我不清楚你正在经历什么,但也许这会对某人有所帮助。

我在带有 form.php 和 transaction.php 文件的 Braintree 沙箱中运行。在 transaction.php 中,我做到了require_once('/lib/Braintree.php');,而 transaction.php 正在死去,永远不会超过require_once声明。

我进入了 Braintree.php 文件的底部,找到了上面写着的那一行throw new Braintree_Exception('The Braintree library requires the ' . $ext . ' extension.');

无论出于何种原因,这就是我的脚本即将死去的那一行。我将其更改throw new为一个echo并再次运行我的 transaction.php 文件 - 并收到 2 条消息说“Braintree 库需要 XXXX 扩展名”。

对我来说,它是 xml-writer 扩展。我在我的服务器上安装了 xml-writer,然后重新启动了 Apache。然后一切都按预期工作。

于 2013-10-09T21:17:19.537 回答