LemonSqueezy
Subscriptions and One-time with LemonSqueezy
For Initial Setup check out the LemonSqueezy docs from Larafast on how to setup One-time payments and Subscriptions.
Products
To get the list of products, you can use the following method:
It uses the products
method from the LemonSqueezyService
class to get the list of products. LemonSqueezyService
is a service class that contains all the methods to interact with the LemonSqueezy API.
You can cache the products to reduce the number of requests to the LemonSqueezy API. Uncomment the lines below the $products
variable to cache the products.
Subscriptions and One-time Payments
Unlike for TALL or VILT stack, in the API we cannot redirect users directly to the payment page. Instead, we need to create a checkout session and return the checkout url to the Frontend or Mobile App. The client then uses the url to redirect the user to the payment page.
Subscriptions
To create a subscription, you can use subscriptionCheckout
method.
It requires variant as parameters. The $product
is the product id from LemonSqueezy Store and $variant
is the variant id.
Redirect the user to the returned url to complete the payment.
One-time Payments
To create a one-time payment, you can use the productCheckout
method.
It requires $variantId
parameter. The $variant
is the variant id in LemonSqueezy Store.
Redirect the user to the returned url to complete the payment.
Webhook
Check out the Webhook docs from Larafast on how to setup the webhook for LemonSqueezy.
Billing Portal
If you want to allow users to manage their subscriptions, you can use the billing portal. Redirect the user to the billing portal url to allow them to manage their subscriptions.
User should be a LemonSqueezy customer (means purchased a product or have a subscription) to access the billing portal.