0
我正在尝试将付款网关添加到我的网站。我在Silex框架的基本实现方面遇到了很多麻烦。从未找到app.php
页面。事实上,我目前使用的测试服务器,并同时signup.php
页面在以下目录:Silex基本表单提交
http://localhost/www/smafo/signup.php
,
提交表单最终导致以下网址http://localhost/create_transaction
导致未找到页面错误。
注:更改表单的action属性来app.php
,路由到正确的app.php
页面并导致Symfony的找不到页面错误。
任何想法,我做错了什么?
这是样表: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();
我非常感谢任何意见。
非常感谢提前!
你下面这个教程是为u? https://www.braintreepayments.com/docs/php/guide/getting_paid您是否错过了Javascript组件? – 2013-04-24 18:18:10
感谢您的回复。是的,我正在尝试遵循可怜的教程。不,我不错过JavaScript组件。 – AnchovyLegend 2013-04-27 15:47:34