![]() |
Stripe Library - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Stripe Library (/showthread.php?tid=79218) |
Stripe Library - paulkd - 05-14-2021 I'm having problems migrating my CI3 Stripe Library to CI4. I've run composer require stripe/stripe-php and a truck load of code has ended up in my vendor folder (as expected). I've created a StripePayments.php file in app/Libraries with the following code Code: <?php But my intelephense vscode linter extension is telling me "Nope, not gonna happen" ![]() I've googled and searched github for a couple of hours now. Hopefully someone here will be able to point me in the right direction ![]() RE: Stripe Library - InsiteFX - 05-14-2021 I believe that you need to add a use clause just above the class name. PHP Code: use Stripe\StripeClient; No sure if that is what is callusing your warning. RE: Stripe Library - paulkd - 05-14-2021 (05-14-2021, 01:32 AM)InsiteFX Wrote: I believe that you need to add a use clause just above the class name. Hi InsiteFX, Thanks very much for your help again. ![]() Unfortunately I'm still getting a thumbs down from intelephense. It is displaying Undefined type 'Stripe\StripeClient' for the Stripe instantiation in the constructor Code: <?php Do you think I should add anything to app\Config\Autoload.php ? RE: Stripe Library - InsiteFX - 05-14-2021 If you add their library then you need to add it to the class map in the autoload. RE: Stripe Library - paulkd - 05-14-2021 Hi InsiteFX, I have a success ![]() Turns out I can ignore the undefined type 'Stripe\StripeClient' error flagged by intelephense, although I suspect intelephense will be strictly correct. btw - the intelephense vcs extension is awesome, if anyone is interested ![]() I'm not an OOP guru, but have grasp of the main concepts. I'm going to post some of my code here , if anyone else is looking to add Stripe to their app. As per the docs, I installed Stripe via composer. I have a FrontController that extends the baseController and then I have a "Front" folder (under app/Controllers) of controllers that extend the FrontController - one of them is called Main.php Here is the beginning of Main.php showing that I've temporarily hijacked the about page to test my Stripe connection. Code: <?php I have a StripePayments.php file under app/Libraries Here is the beginning of the code showing listCustomers and getBalance functions Code: <?php I did not need to add anything to app/Config/Autoload.php Hope this helps others. Feel free to tell me I "this is not the way" or I should be using services ![]() RE: Stripe Library - InsiteFX - 05-14-2021 I personally use the phpStorm editor, doe's all the updates right from the editor. RE: Stripe Library - paulkd - 05-16-2021 ![]() |