Connect Stripe to Project
- Create a Stripe Account and do the initial setup.
Setup API Keys
To connect Stripe to the Larafast project you need to set API keys.- Copy Publishable and Secret Keys from Developers->API Keys
- In your .env file replace the following keys
.env
Subscriptions
To automate subscription creation from the project to Stripe, we have created a command that will create Stripe Products and Prices for you and save you all the hassle. No more manual subscriptions and price setups. (It also can be re-run in case anything changes, to sync the changes to Stripe)- In the project, open
/stubs/stripe/products.json
;
- Next, is Prices (Plans). Open
/stubs/stripe/prices.json
prices.json
you will see the list of example prices. Change the data accordingly.
Columns Explained
Price->ID - It’s the name that you will use for checkout, basically it’s stripe_id for the price Price->Amount - Stripe uses the lowest point for currency, for EUR and USD it’s cents, and the amount should also be specified accordingly:amount: 999
means the product price is $9.99
Price->billing_scheme - Can be per_unit
or tiered
Price->Product - This should be the product->id from products.json for which the price will be created.
To learn more about available columns and settings, check Stripe API Docs for Price Object
Create Products and Prices
After you made your changes and added all your products and prices, run the following artisan command to push all the data to Stripe:resources/js/Components/Plans.vue
update plan->slug with the ID of your price and that’s it! :rocket:
Subscription Checkout URL
web.php
Single Payment Products
If your project does not have subscriptions but has single-payment products, we’ve got you covered here too. Check/stubs/stripe/single_payment_products.json
Do your changes and run:
ProductCheckout URL
web.php
[new] Products and Prices in Database
If you want to use products and prices from the database, you need to add following events to your webhook:stripe:create-products-and-prices
or stripe:create-single-payment-products
the products and prices will be created in the database via webhooks.
That means, that even if you create products and prices manually in the Stripe Dashboard, you will have them in the database and will be able to use them in the project.
To learn more about Products and Prices check app/Listeners/StripeEventListener.php
You can also sync products and prices from the Stripe Dashboard to the database by running:
Stripe URL’s
Larafast comes with stripe subscription and product checkout URLs, which you can find in routes/web.phpweb.php
Middleware
Use pre-definedHttp/Middleware/Subscribed
middleware for subscription-protected routes.
web.php
Customer Portal and Emails
- Turn on Customer Emals for successful payments and refunds

- Turn on the Customer Portal to allow users to manage their subscriptions, and payment methods and see invoices
- If you have subscriptions, make sure to allow users to switch plans and choose prices that are switchable

- Customize your Customer Portal with your brand image and colors
web.php
Webhooks
Laravel Cashier automatically handles the following webhooks out of the box:app/Listeners/StripeEventListener.php
For local testing, you can use Stripe CLI
To learn more about Laravel Cashier check the official documentation