Install and configure Laravel Cashier (Stripe) - 2
We will see the steps to install and configure Laravel Cashier in a Laravel environment.
The composer require Laravel cashier command is nothing unusual, well, just place it here to your project and let this install happily in life:
$ npm install @vue-stripe/vue-stripe
So here we have to wait for the process to finish to run the vendor, the migrations and so on and it creates three tables and the configuration one here we can do this later too where the points for the keys are:
.env
STRIPE_KEY=your-stripe-key
STRIPE_SECRET=your-stripe-secret
We have the configuration part of the keys really only in principle we need only these two this is for the WEBHOOK:
STRIPE_WEBHOOK_SECRET=your-stripe-webhook-secret
That we are not going to deal with it There it goes installing then we place it here at our point you can also copy and paste any that you have around there there is nothing strange that was what I did and Well I'm going to remove this we place it here and here you have to come to your strive to the account that you are supposed to have already created and you enter here in the part My God How do I go back here in start you copy this obviously you use yours please and here the secret one too there to see it copied it hacked me what the hell here is the copied there we put the other one and that would be practically everything so now with this we have the secret and public keys for our stripe and we have to wait for this demon to finish to continue the configuration So we save here really to see if we are going to need the most of all is the configuration file here I also explain a little thing that happened to me that I was precisely configuring stripe in another project with larab cas and already the migration part as I tell you if it is a single payment it would not be necessary because we are not going to do anything with these tables therefore This part depends on what you want to do, you don't have to run the configuration part, it's something very curious, at least for the versioning that I'm currently using, which is Laravel 11, with whatever version of Cashier I'm going to install, which I don't know what it is, right now we'll see it. I didn't publish the configuration file in development, which is a file saved in the config folder called cashier php:
$ php artisan vendor:publish --tag="cashier-config"
We generate the migrations:
$ php artisan vendor:publish --tag="cashier-migrations"
$ php artisan migrate
In which there is basically a reference to the keys that we just copied or configured in development, it didn't give me any problems other than the development environment, I think it's the her or aragon environment that I also used since I used both since I developed on Mac Windows in one I was using in one I had the project in and in the other I had the project in long there it never asked me for the c file. phps never gave me any problems with that but when I went to production and I didn't remember about this command it started giving me a pretty annoying error here, exactly this one that I'm putting here, I'm still writing this that told me that the apik was not provided and it was because it is precisely provided through the configuration file mentioned but the curious thing was that for my development environment I could take it like that or directly for the environment that Laragon prepares for me or not even paying attention to that file but when I went to production it did give me this problem and I didn't know what the hell it was telling me so well pay attention to that too because usually these packages are made so that when you test everything in development it's so easy to go to production by simply changing the keys here and that would be practically everything although you also have to change the payment identifiers and so on but apart from that it gave me that problem that I was telling you about so well since this is over let's go here it is copy and paste and there I hope nobody gets upset that's what we have here this what it does is publish publish from the vendor folder which is where the library is located the migrations and here now it would be a normal migration here you can see the migrations that were generated would be these three customers, the subscriptions and the items for subscriptions, that is to say what the customer would buy, so we execute it and there we have it. The other is the configuration file, so I do recommend that you do this one no matter what, we paste it and we have it and the file in question would be this one that simply publishes the keys here, well, and little else, really, well, it already has several little things, what we are interested in is the keys, so nothing, with this we finish the installation of the arir and we can continue with the next class.
- Andrés Cruz
This material is part of my complete course and book; You can purchase them from the books and/or courses section, Curso y Libro Laravel 11 con Tailwind Vue 3, introducción a Jetstream Livewire e Inerta desde cero - 2025.
Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter