我有一个包含许多文件夹/子文件夹/文件的应用程序,我似乎无法让 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/>");
}
}
?>