2013-04-11 81 views
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(); 

我非常感謝任何意見。

非常感謝提前!

+0

你下面這個教程是爲u? https://www.braintreepayments.com/docs/php/guide/getting_paid您是否錯過了Javascript組件? – 2013-04-24 18:18:10

+0

感謝您的回覆。是的,我正在嘗試遵循可憐的教程。不,我不錯過JavaScript組件。 – AnchovyLegend 2013-04-27 15:47:34

回答

0

我有同樣的問題,並最終設法進行以下替換來解決它:

<form action="app.php/create_transaction" method="POST" id="braintree-payment-form">