codeigniter 3 上的条纹

Stripe on codeigniter 3

我在一个 codeigniter 项目中有 stripe,我已经关注了 Link 1 and Link 2。 我正在研究 lamp Apache 2.4 和 Ubuntu 14 L.T.S

但是,我一直收到 Not found 404.Seems 提示,服务器未获取该路由。 我仔细检查了我的控制器和视图,但没有发现任何错误。

Paymentclass里面的支付方式是:

public function pay(){

  require_once('vendor/autoload.php');

  $token  = $_POST['stripeToken'];

  \Stripe\Stripe::setApiKey("sk_test_somekey");

  $customer = \Stripe\Customer::create(array(
      'email' => 'customer@example.com',
      'source'  => $token

  ));

  $charge = \Stripe\Charge::create(array(

      'customer' => $customer->id,
      'amount'   => 5000,
      'currency' => 'usd'

  ));
  echo '<h1>Successfully charged .00!</h1>';
}

我视图中的表格如下:

<?php require_once('vendor/autoload.php'); ?>

<form action="Payment/pay" method="post">
  <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
          data-key="pk_test_some_key"
          data-description="Access for a year"
          data-amount="5000"
          data-locale="auto">
 </script>
</form>

我正在使用 composer,所以配置文件被修改为:

$config['composer_autoload'] = APPPATH.'vendor/autoload.php';

Apache吐槽:

The requested URL /Payment/pay was not found on this server.

非常欢迎任何指点。

编辑:routes.php 看起来像:

$route['default_controller'] = 'payment';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

我找到了一个解决方案并想分享它。

确保你的代码有:

$autoload['helper'] = array('url');

如果您有 .htaaccess,请确保它可以在没有 index.php 的情况下为每个请求加载。就我而言,我有类似的东西:

RewriteEngine on
RewriteCond  !^(index\.php|images|assets|uploads|robots\.txt)
RewriteRule ^(.*)$ /index.php/  [L]

无论出于何种原因都没有帮助,所以我最终将其删除并在路线上留下 index.php,我知道,它很丑。

最后,我按照建议将 index.php 添加到表单的操作路径中并且成功了。

希望对大家有所帮助。

致谢并感谢@TheDrot 指出。