RAT
RAT

Reputation: 135

trying to setup stripe api with php and getting an error saying "Undefined type 'Stripe\StripeClient'."

So i followed the installation process on stripes website and i'm currently getting an error saying that "undefined type 'Stripe/StripeClient.'"

CODE:

<?php
    require_once('vendor/autoload.php');
    $stripe = new \Stripe\StripeClient(
        ''
      );
      $stripe->customers->retrieve(
        'cus_HjS2guMajCRCG5',
        []
      );
?>

Upvotes: 2

Views: 1628

Answers (1)

RAT
RAT

Reputation: 135

So i managed to get this working with the following code:

<!DOCTYPE html>
<html>
    <head>
    <script
  src="https://code.jquery.com/jquery-3.5.1.min.js"
  integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
  crossorigin="anonymous"></script>
    </head>
<body>

<?php
require_once('vendor/autoload.php');
$firstname = $_POST["inputFirstName"];

$lastname = $_POST["inputLastName"];

$email = $_POST["emailaddress"];

$discordid = $_POST["discordid"];

$stuff = array($firstname, $lastname, $email, $discordid);
echo implode(" ",$stuff);

$stripe = new \Stripe\StripeClient(
    'HIDDENFORPRIVACYREASONS'
  );
  $stripe->customers->create([
      'name' => $firstname . " " . $lastname,
      'email' => $email, 
    'description' => $discordid,
  ]);

?>
</body>
</html> 

Upvotes: 1

Related Questions