Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Undefined type 'Stripe\StripeClient' while integrating Stripe with my php project

Pardon me if this has been asked already. I am a beginner trying to integrate stripe payment gateway in my PHP sample project. I installed stripe API using composer from stripe github page. using composer require stripe/stripe-php in my project directory. require_once 'vendor/autoload.php'; is working just fine. but simple usage code is not working properly

 $stripe = new \Stripe\StripeClient('my secret key would be here');
    $customer = $stripe->customers->create([
        'description' => 'example customer',
        'email' => 'email@example.com',
        'payment_method' => 'pm_card_visa',
    ]);
    echo $customer;
  1. cURL
  2. JSON
  3. mbstring
    are already installed and available in my system.

enter image description here

I tried solution described in this stack overflow post

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

but no positive results appeared. Thanks in advance.

>Solution :

try like this:

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

\Stripe\Stripe::setApiKey('stripe_sectet_key');


$customer = \Stripe\Customer::create([
    'description' => 'example customer',
    'email' => 'email@example.com',
    'payment_method' => 'pm_card_visa',
]);

echo $customer;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading