Are you looking to sell subscriptions to your website or web app? Chances are, you want to use Stripe to accept payments. Enter Cartalyst Stripe stage right. Cartalyst Stripe is a powerful package designed to give you a bit more customization over Laravel's Cashier. It has many functions. It is very easy to use. And, there is tons of documentation in case you ever get lost.
First, install the Cartalyst Stripe package with Composer. You can view the Cartalyst Stripe documentation you will need for Laravel 5.8 here. Add the following to your /composer.json file in Laravel.
Now run one of the following commands.
php composer install
php composer update
Now add Cartalyst Stripe to your /config/app.php like so. First under the $providors array add the following line:
And, under the $aliases array and this line:
'Stripe' => Cartalyst\Stripe\Laravel\Facades\Stripe::class,
First we will figure out what your Stripe API codes are. Head over to stripe.com, login, and go to your dashboard. Navigate to Developers > API keys. Here you will see a publishable key and a secret key. You will need both. However, it is a good idea to use the testing keys so that you can feel things out before you are ready for production. To do this, simply click on View test data to switch the keys.
Next, add these two lines to your /.env file adding your keys after each of the "=" signs. We are adding these keys to your .env file to keep them out of the public space where prying eyes can see and use them.
Next add the following code to your /config/services.php file. Notice it will pull your keys from the environment file that we updated. Cool! Huh?
'stripe' => [ 'key' => env('STRIPE_PUBLIC_KEY'), 'secret' => env('STRIPE_SECRET_KEY'), ],
Everytime you use Cartalyst Stripe, you will need the following three lines. Add this line to the top of your controller or wherever you're going to use the Cartalyst Stripe package:
Now create a new instance of the Cartalyst Stripe package by doing the following:
$stripe = new Stripe('your-stripe-api-key'); $stripe = Stripe::make('your-stripe-api-key');
Now you can do it all. Pretty much every time you want to capture credit card information or process a payment in Cartalyst Stripe, you will need to create a new customer. But Cartalyst Stripe does it all. You can create customers, cards, subscriptions, plans, and even make a one time charge. There is lots more. Check out the Stripe by Cartalyst page to learn more.
Discover the awesome and affordable possibilities of web page and application design by stupendous.dev Web Design. I will deliver you the web design or ecommerce site you need to succeed. Say hello and let's talk more about your goals. I can't wait to see what you're cooking up.