Preface
Introduction
A Laravel 6 integration for the Cartalyst Stripe package.
The package requires PHP 7.2 and follows the FIG standard PSR-1, PSR-2 and PSR-4 to ensure a high level of interoperability between shared PHP code.
Have a read through the Installation Guide.
Setup
Installation
Cartalyst packages utilize Composer, for more information on how to install Composer please read the Composer Documentation.
Preparation
Open your composer.json
file and add the following to the require
array:
"cartalyst/stripe-laravel": "^11.0"
Note: Make sure that after the required changes your
composer.json
file is valid by runningcomposer validate
.
Install the dependencies
Run Composer to install or update the new requirement.
php composer install
or
php composer update
Integration
Integration on Laravel 6 is straightforward.
Set the Service Provider and Facade alias
After installing the package, open your Laravel config file located at config/app.php
and add the following lines.
In the $providers
array add the following service provider for this package.
Cartalyst\Stripe\Laravel\StripeServiceProvider::class,
In the $aliases
array add the following facade for this package.
'Stripe' => Cartalyst\Stripe\Laravel\Facades\Stripe::class,
Set the Api Key
Now you need to setup the Stripe API key, to do this open or create the config/services.php
file, and add or update the 'stripe'
array:
<?php
return [
'stripe' => [
'secret' => 'your-stripe-key-here',
],
];
Set the Api Version (optional)
This step is not necessary, but in case you need to use a previous version of Stripe you can do same process as above and add a 'version'
key on the array:
<?php
return [
'stripe' => [
'secret' => 'your-stripe-key-here',
'version' => '2019-02-19',
],
];
Usage
For usage, please refer to the Cartalyst Stripe package documentation, located here.
Just use the Laravel facade alias Stripe::
instead of the native call $stripe->
.
Enjoy :)