【发布时间】:2013-04-11 18:16:27
【问题描述】:
我正在尝试向我的网站添加支付网关。我在 Silex 框架的基本实现方面遇到了很多麻烦。永远找不到app.php 页面。事实上,我目前正在使用测试服务器,而 signup.php 页面位于以下目录中:
http://localhost/www/smafo/signup.php,
提交表单最终会导致以下 url http://localhost/create_transaction 导致页面未找到错误。
注意:将表单的 action 属性更改为 app.php,路由到正确的 app.php 页面并导致 Symfony Page not found 错误。
有什么想法我在这里做错了吗?
这是示例表单:signup.php
<form action="/create_transaction" 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" data-encrypted-name="month" /> / <input type="text" size="4" data-encrypted-name="year" />
</p>
<input type="submit" id="submit" />
</form>
这是我的 app.php(与 signup.php 在同一目录中)
$app = new Silex\Application();
$app->get('/', function () {
include 'signup.php';
return '';
});
$app->post('/create_transaction', function (Request $request) {
echo 'YES';
$result = Braintree_Transaction::sale(array(
'amount' => '1000.00',
'creditCard' => array(
'number' => $request->get('number'),
'cvv' => $request->get('cvv'),
'expirationMonth' => $request->get('month'),
'expirationYear' => $request->get('year')
),
'options' => array(
'submitForSettlement' => true
)
));
if ($result->success) {
return new Response("<h1>Success! Transaction ID: " . $result->transaction->id . "</h1>", 200);
} else {
return new Response("<h1>Error: " . $result->message . "</h1>", 200);
}
});
$app->run();
我非常感谢任何建议。
非常感谢!
【问题讨论】:
-
您正在学习本教程,不是吗? braintreepayments.com/docs/php/guide/getting_paid你是不是缺少Javascript组件?
-
感谢您的回复。是的,我正在尝试遵循糟糕的教程。不,我没有错过 javascript 组件。
标签: php forms frameworks routing silex