'Class "Stripe\Stripe" not found in codeigniter 4

i downloaded stripe php library by using Composer with this command

composer require stripe/stripe-php


then i added this in my app/config/autoload.php

public $psr4 = [        APP_NAMESPACE => APPPATH, // For custom app
     namespace      'Config'      => APPPATH . 'Config',        
'Stripe' =>> ROOTPATH . 'vendor/stripe/stripe-php/init.php' // added here   ];

then in controller i added this code but it giving me error Stripe/Stripe Not found

use Stripe; 
\Stripe\Stripe::setApiKey(STRIPE_SECRET);    

         $paymentData = \Stripe\Charge::create ([
                 "amount" => $this->request->getPost('grandtotal'),
                 "currency" => "GBP",
                 "source" => $_REQUEST["stripeToken"],
                 "description" => "Test payment via Stripe From Rahul" 
         ]);
         $paymentData = array('success' => true, 'data'=> $stripe);
        
         echo '<pre>' , var_dump($paymentData) , '</pre>';

i followed one tutorial but it giving me this error, please help me



Solution 1:[1]

You could use autoloader to actually include the Stripe classes...

require_once('vendor/autoload.php');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nilesh