PHP条带集成

I've been having trouble integrating Stripe into my website as it seems every time I solve a problem a different one arises.

I've decided to use the local Stripe folder library instead of installing it.

My buy page looks like this:

<body>

    <?php require_once('./config.php'); ?>

    <form action="charge.php" method="post">
    <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
      data-key="<?php echo $stripe['publishable_key']; ?>"
      data-description="Access for a year"
      data-amount="5000"
      data-locale="auto"></script>
 </form>           
</body>

My charge.php looks like this:

<?php
  require_once('./config.php');
  $token  = $_POST['stripeToken'];
  $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 $50.00!</h1>';
?>

Lastly, my config.php: (stars replaced my keys)

<?php
require_once('./Stripe/init.php');
$stripe = array(
  "secret_key"      => "sk_test_***********************",
  "publishable_key" => "pk_test_***********************"
);
\Stripe\Stripe::setApiKey($stripe['secret_key']);

My Stripe library folder is on the same level as my other pages, which could be my problem, to present this I'll make a leveled bullet list:

  • config.php
  • index.php
  • charge.php
  • Stripe (folder)
    • Contents in folder

What am I doing wrong? I've uploaded my folder to my Webhost server and when I go to the page where there's supposed to be a button, I receive an error:

Warning: require(/home1/desmoriz/public_html/Stripe/lib/AttachedObject.php): failed to open stream: No such file or directory in /home1/desmoriz/public_html/Stripe/init.php on line 32

Fatal error: require(): Failed opening required '/home1/desmoriz/public_html/Stripe/lib/AttachedObject.php' (include_path='.:/opt/php56/lib/php') in /home1/desmoriz/public_html/Stripe/init.php on line 32

I guess you've checked that the file AttachedObject.php is effectively folder.

Also check that che CHMOD of all your Stripe folder and its sub-folders/files is set to 755 so that you PHP can access the files in it.