LemonSqueezy for Non-Auth Users in Laravel
How to integrate LemonSqueezy for non-auth users in Laravel
Laravel LemonSqueezy package default checkouts are made for only registered users, same for webhooks to save orders. But you can use LemonSqueezy API to create checkouts for non-auth users and save orders in your database.;
Check the LemonSqueezy Webhooks for Non-Auth Users guide for Non-Auth users integration.
To get product payment links and use them for non-auth users, you can use app/Services/LemonSqueezyService.php
( Remember to add LemonSqueezyServiceProvider::class to the config/app.php providers list)
LemonSqueezyService uses LemonSqueezyAPI -> https://docs.lemonsqueezy.com/api
Products
To retrieve the products, use the products() method from the Service,
Variants
For each product, you can retrieve its own variant by providing the product ID,
Products with no variants
If your product does not have any variants, in other words, if it has only one price, in the Product Object attributes you will see “buy_now_url” which can be used for checkout.
To apply the discount code in the checkout URL you can add the following after your URL
?checkout[discount_code]=YOUR_DISCOUNT_CODE
Products with multiple variants
If the product has multiple variants, to create a checkout URL dynamically use the “checkout” method from the Service. The checkout method accepts variant ID and creates URL.
Example for Single Variant Products
Use $products
variable in your view files to display pricing tables
To read about LemonSqueezy integration for Auth users, check the LemonSqueezy for Auth Users guide.