我有一个包含许多文件夹/子文件夹/文件的应用程序,我似乎无法让Braintree正常工作。有什么我只是在这里失踪?假设我的网站名称是DIR。Braintree API不能在PHP应用程序中工作
所有从布伦特里文件夹解压文件都在DIR/braintree_payments
然后我transaction.php文件在DIR /模板/内容/上市
所有形式的标签是在DIR /模板/内容/上市/ 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/>");
}
}
?>
此外,包含confirm_booking.tpl.php的html页面从DIR/modules/listing/confirm_booking.php链接。所以modules/listing/confirm_booking.php位于url – pmanning
嘿@pmanning,你是否在你的'require_once'中添加了'../'? 'require_once'../ braintree_payments/lib/Braintree.php';'如果这不能解决它,请更具体然后“无法正常工作”此外,我已编辑您的帖子,以删除您的私钥。即使它只是一个沙箱帐户,你应该保持私密。 – agf
是的,我试过没有运气。并感谢编辑,但我只是在一些文本中涂写这些不是真正的键。它重定向到我的主页,然后在我的沙盒帐户中没有任何内容显示。 – pmanning