Slim 3 和 Stripe API 兼容性问题
Slim 3 & Stripe API compatibility issues
我使用 Slim 3 启动了一个 Web 应用程序。我去添加 Stripe API 并收到一条 Slim 应用程序错误消息。我删除了 Stripe API 代码,错误消失了。
// Setup
\Stripe\Stripe::setApiKey('xx_test_XXXXxXxXXXXXxXxXXxXXXxXX');
// Get Token
$token = $_POST['stripeToken'];
// Charge the user's card:
$charge = \Stripe\Charge::create(array(
"amount" => 1000,
"currency" => "usd",
"description" => "Example charge",
"source" => $token,
));
我用谷歌搜索了一些东西,但仍然没有找到问题的根源。我怀疑 \Stripe\
是罪魁祸首,但我不知道为什么会这样。
当您从 Slim Framework 获得空白错误页面时,您可以通过两种方式找出实际错误:
- 检查你的 PHP
error_log
因为 Slim 会把错误写在那里。
更新您的 settings
以将 displayErrorDetails
设置为 true
。
即
$config = [
'settings' => [
'displayErrorDetails' => true, // set to false in production
'addContentLengthHeader' => false, // Allow the web server to send the content-length header
],
];
$app = new \Slim\App($config);
错误消息页面现在将显示实际错误的详细信息。
希望您随后能够找出问题所在。
我使用 Slim 3 启动了一个 Web 应用程序。我去添加 Stripe API 并收到一条 Slim 应用程序错误消息。我删除了 Stripe API 代码,错误消失了。
// Setup
\Stripe\Stripe::setApiKey('xx_test_XXXXxXxXXXXXxXxXXxXXXxXX');
// Get Token
$token = $_POST['stripeToken'];
// Charge the user's card:
$charge = \Stripe\Charge::create(array(
"amount" => 1000,
"currency" => "usd",
"description" => "Example charge",
"source" => $token,
));
我用谷歌搜索了一些东西,但仍然没有找到问题的根源。我怀疑 \Stripe\
是罪魁祸首,但我不知道为什么会这样。
当您从 Slim Framework 获得空白错误页面时,您可以通过两种方式找出实际错误:
- 检查你的 PHP
error_log
因为 Slim 会把错误写在那里。 更新您的
settings
以将displayErrorDetails
设置为true
。
即$config = [ 'settings' => [ 'displayErrorDetails' => true, // set to false in production 'addContentLengthHeader' => false, // Allow the web server to send the content-length header ], ]; $app = new \Slim\App($config);
错误消息页面现在将显示实际错误的详细信息。
希望您随后能够找出问题所在。