LemonSqueezy
Documentation for Larafast
Connect LemonSqueezy to Project
- Create a LemonSqueezy Account and set up your store
Setup API Keys
To connect LemonSqueezy to the Larafast project you need to set API keys.
- Create an API token in your account from https://app.lemonsqueezy.com/settings/api
- Add
LEMON_SQUEEZY_API_KEY=
variable to .env file with API key - Add Store ID to .env
LEMON_SQUEEZY_STORE=
You can find your store ID in your Settings->Stores page
P.S. Use it without #, (made that mistake by myself :D )
Migrations
To publish LemonSqueezy migration files, run the following command
Subscriptions
Create your products in LemonSqueezy -> https://app.lemonsqueezy.com/products and choose “Subscription” for the pricing option.
After the product is created, copy the Product ID and Variant ID to use in the subscription checkout URL.
To find a Product ID and Variant ID, go to your products page-> https://app.lemonsqueezy.com/products
Unlike Stripe, LemonSqueezy requires and product and variant ID to be sent for checkout.
Checkout URL:
That’s it. You are ready to accept subscriptions 🙌
Single Payment Products
Create your products in LemonSqueezy -> https://app.lemonsqueezy.com/products and choose “Single Payment” for the pricing option.
After the product is created, copy the Variant ID to use in the product checkout URL.
To find a Variant ID, go to your products page-> https://app.lemonsqueezy.com/products
For Single Payment products, you need only variant ID
Checkout URL:
If you want to have a product checkout without logged in users, use LemonSqueezyService.php to retrieve products and product buy now links.
LemonSqueezy URL’s
Larafast comes with all URL’s pre-defined, you can find them in routes/web.php
Middleware
Use pre-defined Http/Middleware/Subscribed
middleware for subscription-protected routes.
Customer Portal
To redirect users to their Customer Portal for Subscription and Orders management use /billing route
Webhooks
Finally, make sure to set up incoming webhooks. This is both needed in development and production.
Webhooks In Development
The easiest way to set this up while developing your app is with the php artisan lmsqueezy:listen
command that ships with this package. This command will setup a webhook through the Lemon Squeezy API, start listening for any events and remove the webhook when quitting the command.
Although this command should always cleanup the webhook after itself, you may wish to cleanup any lingering webhooks with the --cleanup
flag:
Currently, this command supports Ngrok and Expose.
Webhooks In Production
For production, we’ll need to set things manually. Go to your Lemon Squeezy’s webhook settings and point the URL to your app’s domain. The path you should point to is /lemon-squeezy/webhook
by default. Make sure to select all event types.
We also very much recommend to verify webhook signatures in production.
Add LEMON_SQUEEZY_SIGNING_SECRET=
in your .env file
To read more about Laravel and LemonSqueezy integration check the LemonSqueezy Laravel package doc-> https://github.com/lmsqueezy/laravel