Re: [stripe-api-discuss] Uncaught Error: Class 'Stripe\Stripe' not found in

160 views
Skip to first unread message
Message has been deleted

Fred Alger

unread,
Jan 18, 2019, 12:30:19 PM1/18/19
to Stripe API Discussion
Hi there,

Sorry things aren't working as expected! Your code looks just fine, and it sounds like PHP is able to find the Stripe library—require_once will throw an error if the included file can't be found. Using the same code and version of stripe-php on my own system I can't seem to reproduce the error at all. Could you tell me more about your PHP setup? What version of PHP are you using, what SAPI (Apache, FastCGI, etc) are you using?

You also mentioned a plugin; are you embedding stripe-php within a larger framework such as Drupal or Wordpress? In general frameworks can affect how script loading happens, so any more information you can share here would be helpful! I realize that this may not be information you wish to share on a public list, so I'd encourage you to reach out to sup...@stripe.com to share any code or specific details.

Best,
- Fred.


On Fri, Jan 18, 2019 at 10:58 AM <khit...@onlinedateshare.com> wrote:
Newbie alert. Trying to start the api for stripe. Here is the code thus, far:

//cannot get this to work states err "Uncaught Error: Class 'Stripe\Stripe' not found in..." 

require_once('stripe-php-6.28.0/init.php');

$stripe = [
  "secret_key"      => "sk_test_identifier here",
  "publishable_key" => "pk_test_identifier here",
];

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


 $pid = $_GET['pid'];
 $token  = $_POST['stripeToken'];
  $email  = $_POST['stripeEmail'];

  $customer = \Stripe\Customer::create([
      'email' => $email,
      'source'  => $token,
  ]);

\Stripe\Subscription::create([
  "customer" => $customer->id,
  "items" => [
    [
      "plan" => "plan_identifier here",
    ],
  ]
]);
 

  echo '<h1>Successfully charged $5.00!</h1>';
 
?>
<form action="https://mydomain.com/activated" method="POST" <?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>>
  <script
    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
    data-key="pk_test_identifier here"
    data-amount="500"
    data-name="mydomain.com"
    data-description="Subscription(s)"
    data-locale="auto"
    data-currency="usd"
    data-zip-code="true">
  </script>

</form>
I loaded the folder
stripe-php-6.28.0/init.php

in the same folder as the plugin page.  Getting error 
"Uncaught Error: Class 'Stripe\Stripe' not found in..."

I have looked through the stripe php folder and do not see what is referenced. 
Any assistance would be greatly appreciated.

--
You received this message because you are subscribed to the Google Groups "Stripe API Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.
To post to this group, send email to api-d...@lists.stripe.com.
Visit this group at https://groups.google.com/a/lists.stripe.com/group/api-discuss/.
Reply all
Reply to author
Forward
0 new messages