0

SOLUTION: CURL-PHP5 WAS NOT INSTALLED BE SURE TO ENABLE ERRORS IN PHP

Guide I followed: https://stripe.com/docs/checkout/guides/php

Path to the Stripe PHP Library: /var/www/stripe-php/lib/Stripe.php or /stripe-php/lib/Stripe.php

Error Message: Fatal error: Class 'Stripe_Customer' not found in /var/www/charge.php on line 9

index.php:

<?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-amount="2000" data-billing-address data-description="Test"></script>
</form>

config.php: (the keys are just test ones provided by stripe)

<?php
require_once('stripe-php/lib/Stripe.php');

$stripe = array(
  "secret_key"      => "sk_test_************************",
  "publishable_key" => "pk_test_************************"
);

Stripe::setApiKey($stripe['secret_key']);
?>

charge.php:

<?php
 error_reporting(E_ALL);
 ini_set("display_errors", 1);

  require_once(dirname(__FILE__) . '/config.php');

  $token  = $_POST['stripeToken'];

  $customer = Stripe_Customer::create(array(
      'email' => 'customer@example.com',
      'card'  => $token
  ));

  $charge = Stripe_Charge::create(array(
      'customer' => $customer->id,
      'amount'   => 2000,
      'currency' => 'usd'
  ));

  echo '<h1>Successfully charged $20.00!</h1>';
?>
Sam
  • 20,096
  • 2
  • 45
  • 71
EEEE
  • 61
  • 1
  • 7
  • In the config you have `require_once('stripe-php/lib/Stripe/Stripe.php');` but then you say the path is `/stripe-php/lib/Stripe.php`. That seems inconsistent to me. – Pete Keen Apr 17 '14 at 16:23
  • Can you do a `echo 'test';` in `config.php` to make sure it is being successfully included in `charge.php`? Also, why `dirname(__FILE__)` instead of `__DIR__`? – Sam Apr 17 '14 at 18:37
  • I just hid your test keys. Some people will still be able to see the revisions though, so I highly recommend you change them on Stripe. Even though they are just test keys, you wouldn't like someone skewing all of your tests by posting charges. – Sam Apr 17 '14 at 18:40
  • One final question, whats your absolute path to `config.php`? Is it `/var/www/config.php`? – Sam Apr 17 '14 at 18:44
  • possible duplicate of [stripe configuration issue](http://stackoverflow.com/questions/23127362/stripe-configuration-issue) – Marcus Olsson May 09 '14 at 08:54

1 Answers1

0

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

$stripe = array(
  "secret_key"      => "sk_test_duZNCP2a1Hf2KL2BX5ShdD8N",
  "publishable_key" => "pk_test_plGLUfjyTapopWA0ZQY8UdSt"
);

\Stripe\Stripe::setApiKey($stripe['secret_key']);
?>

The require_once() line assumes you’ve installed the Stripe PHP library via Composer.

Could not input open file: composer.phar

adabusra
  • 7
  • 6