dongpinken0498 2017-04-04 23:51
浏览 44
已采纳

Slim 3&Stripe API兼容性问题

I started a web application using Slim 3. I went to add in the Stripe API and got a Slim Application error message. I removed the Stripe API code, and the error went away.

// 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,

));

I've Googled a few things, but still haven't found the source of the problem. I suspect that the \Stripe\ is the culprit, but I don't know why it is.

  • 写回答

1条回答 默认 最新

  • douhu7807 2017-04-05 10:12
    关注

    When you get a blank error page from Slim Framework you can find out the actual error in two ways:

    1. Check your PHP error_log as Slim will write the error there.
    2. Update your settings to set displayErrorDetails to true.
      i.e.

      $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);
      

      The error message page will now display the details about what is actually wrong.

    Hopefully, you'll then be able to figure out what the problem is.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?