Accept payments through Lemon Squeezy, a merchant of record: Lemon Squeezy sells to your customers in its own name, collects the sales tax or VAT of their country, and pays you out. Every selling add-on of your site (Shop, Wallet, Stock Media, Booking, Events, Courses...) can offer it at checkout.
Hosted Checkout
Customers pay on the secure Lemon Squeezy checkout by card, PayPal, Apple Pay or Google Pay, then come back to your site.
Merchant of Record
Lemon Squeezy handles sales tax, VAT, invoices and payment disputes worldwide. You receive the payouts.
One Product for Everything
No need to copy your catalog: every payment uses one Lemon Squeezy product, whose price and name are replaced by those of the order.
Signed Webhooks
Payments are confirmed by signed webhooks, and each order is checked against the checkout your site created before it is accepted.
Use Cases
Selling digital products worldwide
You sell digital products, courses or credits to customers in many countries and do not want to register for VAT or sales tax in each of them. Lemon Squeezy adds the right tax at checkout and files it for you.
A second payment method
You already accept Stripe or PayPal and want a merchant of record next to it. In Settings → Payment methods, offer Lemon Squeezy only on the add-ons where you need it (for example the Wallet but not the Shop).
Testing before going live
Lemon Squeezy has a full test mode with test cards: build and check your whole buying flow without any real charge, then switch to live mode.
Requirements
- Larapen CMS v1.0.17 or later
- PHP 8.3+
- MySQL 8.0+
- At least one selling add-on active: Shop, Wallet, Stock Media, Appointment, Booking, Events, Billing, POS, Accounting, Ad Manager or Courses
- A Lemon Squeezy account with a store: lemonsqueezy.com (live payments need an activated store)
- Your site reachable over HTTPS from the Internet, so that Lemon Squeezy can send the webhooks
- The Laravel scheduler running (
php artisan schedule:runevery minute) for the hourly reconciliation
Installation
Step 1: Upload the Add-on
In the admin panel, go to Admin → Extensions → Add-ons and click the Upload Add-on button. Select the add-on’s ZIP file: the system extracts it automatically and the add-on appears in the installed add-ons list.
Step 2: Activate the Add-on
Find Lemon Squeezy Payment Gateway in the list and click Activate. Its database table and permissions are set up automatically.
Step 3: Configure
Prepare your Lemon Squeezy store (see Lemon Squeezy Setup), then fill in Admin → Lemon Squeezy → Settings (see Settings) and click Verify connection.
Lemon Squeezy appears at checkout as soon as the API key, the store ID, the variant ID and the webhook signing secret are all set.
Purchase Code (License Key)
Lemon Squeezy Payment Gateway is sold as a separate product, so it has its own purchase code (license key), distinct from the purchase code of the main application and from the one of every other add-on. You are asked for it when you activate Lemon Squeezy Payment Gateway in Admin panel → Add-ons.
Our products are sold on three platforms. The way you receive a purchase code depends on where you bought the product.
| Platform / Marketplace | How you get the purchase code | Where to find it again |
|---|---|---|
| bedigit.com Store In-site purchase (Shop) |
Generated automatically when the order is paid, then sent by email, either in its own license email, or inside the order confirmation email. | My Account → My Licenses on bedigit.com |
| Gumroad | Created as soon as Gumroad notifies us of the sale, then sent in a separate email, in addition to the Gumroad receipt. | The license email, your Gumroad Library, and My Account → My Licenses on bedigit.com |
| Envato Market CodeCanyon |
Issued by Envato, not by us, and never sent by email: you download it yourself from your Envato account. | Envato account → Downloads → License certificate & purchase code |
1. bedigit.com Store (in-site purchase)
- As soon as the order’s payment status becomes Paid, a license key is generated automatically for every licensed item in the order (one key per purchased unit: buying 3 units gives 3 distinct keys).
- It is emailed to the address used on the order, either in a dedicated license email or inside the order confirmation email. Check your inbox and your spam / junk folder.
- The key stays available in your account under My Account → My Licenses. Keys are masked in the list; open the license detail page to reveal and copy the full key, see the domains it is activated on, and deactivate a domain to free an activation slot.
- The matching invoice is under My Account → My Orders.
2. Gumroad
- A Gumroad purchase produces two separate emails: the Gumroad receipt (sent by Gumroad, giving access to the files) and a license key email (sent by bedigit.com) that contains your purchase code.
- The license key email is generated as soon as Gumroad notifies us of the sale, so it normally arrives within seconds of the payment. Here too, check your inbox and your spam / junk folder.
- When the Gumroad product uses Gumroad’s own license-key feature, the same key also appears in your Gumroad receipt and under Library → your purchase on gumroad.com.
- Use the same email address on bedigit.com as on Gumroad: your keys are then linked to your account automatically and listed under My Account → My Licenses, even if you register after the purchase. You can also add a Gumroad key manually from My Account → My Gumroad Licenses.
3. Envato Market (CodeCanyon)
- Envato purchase codes are issued and delivered by Envato Market, never emailed by us, so there is nothing to look for in your spam folder: you retrieve the code from your Envato account.
- Log in to your Envato / CodeCanyon account, open the Downloads page, find the item, and choose License certificate & purchase code from the Download dropdown. The code is written in that certificate.
- An Envato purchase code looks like
12345678-90ab-cdef-1234-567890abcdef(8-4-4-4-12 characters). It never changes, and renewing item support does not issue a new one. - Official Envato article: Where Is My Purchase Code?
Lemon Squeezy Setup
Everything below is done in your Lemon Squeezy dashboard. The dashboard has a Test mode switch: API keys and webhooks created in test mode only work in test mode, so do this setup once in test mode, and once again in live mode when you go live.
1. API Key
- Open Settings → API.
- Click + (create API key), give it a name (e.g. My website) and copy the key. It is only shown once.
2. Payment Product
Lemon Squeezy only sells existing products, so the add-on uses one product for every payment: each checkout replaces its price by the amount of the order and its name by the order description. Your customers never see the product itself.
- Open Store → Products and click New product.
- Name it, e.g. Order payment, and choose Single payment pricing with any price (it is always replaced).
- Set the tax category that matches what you sell (e.g. Software / SaaS or eBooks): Lemon Squeezy computes the tax from it.
- Publish the product.
3. Store & Variant IDs
- Store ID: open Settings → Stores. The store ID is the number shown next to the store name (after the
#). - Variant ID: every product has at least one variant. Open the product, then the menu of its variant and copy its ID. You can also list the variants with the API:
curl -H "Authorization: Bearer YOUR_API_KEY" -H "Accept: application/vnd.api+json" \ "https://api.lemonsqueezy.com/v1/variants?filter[product_id]=YOUR_PRODUCT_ID"
Once saved, the Verify connection button shows the store and variant names it found, so you know the IDs are right.
4. Webhook
- Open Settings → Webhooks and click +.
- Callback URL: the URL shown in the Webhook tab of the add-on settings,
https://your-site.com/lemonsqueezy/webhook. - Signing secret: type a random string of 6 to 40 characters and keep it: you paste the same value in the add-on settings.
- Events: tick
order_createdandorder_refunded. To bill the Wallet plans, also ticksubscription_created,subscription_updated,subscription_cancelled,subscription_resumed,subscription_expired,subscription_payment_success,subscription_payment_failedandsubscription_payment_recovered(the Webhook tab lists them). - Save.
Environment Variables
The admin settings take precedence. These .env variables are only used while a setting is empty:
| Variable | Default | Description |
|---|---|---|
LEMONSQUEEZY_API_KEY | empty | API key |
LEMONSQUEEZY_WEBHOOK_SECRET | empty | Webhook signing secret |
LEMONSQUEEZY_STORE_ID | empty | Store ID |
LEMONSQUEEZY_VARIANT_ID | empty | Variant used for every payment |
LEMONSQUEEZY_TEST_MODE | true | Create test checkouts |
LEMONSQUEEZY_CURRENCY | USD | Currency of the store |
LEMONSQUEEZY_MONTHLY_VARIANT_ID | empty | Subscription variant billing the Wallet plans every month |
LEMONSQUEEZY_YEARLY_VARIANT_ID | empty | Subscription variant billing the Wallet plans every year |
LEMONSQUEEZY_CHECKOUT_EXPIRES | 1440 | Minutes a checkout link stays valid |
Admin: Settings
Go to Admin → Lemon Squeezy. The page needs the lemonsqueezy.settings.view permission, and saving needs
lemonsqueezy.settings.edit. A badge at the top shows whether the site is in Test mode or Live mode.
Store & API tab
| Field | Description |
|---|---|
| API Key | The key created in step 1. Stored encrypted; leave it empty to keep the current value. |
| Store ID | The number of your store. |
| Variant ID | The variant of the payment product. |
Payment Options tab
| Field | Description |
|---|---|
| Test Mode | On: checkouts are created in test mode (test cards, no real charge). Orders paid in the other mode are never accepted. |
| Store Currency | The currency of your Lemon Squeezy store, e.g. USD or EUR. |
Webhook tab
Shows the webhook URL to copy into Lemon Squeezy, the events to tick, and the Signing Secret field (stored encrypted).
Wallet Plans tab
Shown while the Wallet add-on is active: the Monthly Variant ID and Yearly Variant ID of the subscription product billing the Wallet plans. See Wallet Plans (Subscriptions).
Verify connection
Click Verify connection after saving. The add-on reads your store and variant through the API and tells you:
- that the store and the variant were found, with their names and the store currency;
- or that the currency set in the add-on differs from the store currency;
- or that the signing secret is missing;
- or that a Wallet plan variant is not a subscription billed every month (or every year);
- or the error returned by Lemon Squeezy (wrong API key, unknown store or variant...).
Payment Methods per Add-on
By default Lemon Squeezy is offered on the checkout of every active selling add-on. In Admin → Settings → Payment methods, untick it for the add-ons where it must not be offered.
Payment Flow
- The customer chooses Lemon Squeezy at checkout. The order is created on your site, unpaid.
- Your site creates a Lemon Squeezy checkout for that order: the payment product at the order amount, named after the order, with the customer’s email and name already filled in.
- The customer is redirected to the Lemon Squeezy checkout, where the tax of their country is added, and pays.
- Lemon Squeezy sends the
order_createdwebhook. Your site checks it (see Security Checks) and marks the order as paid: the selling add-on then does what it does for any paid order (credits, downloads, confirmation emails...). - Lemon Squeezy sends the customer back to a confirmation page of your site, which waits a few seconds for the webhook and then opens the success page of the selling add-on. If the webhook takes longer than a minute, the page says that the order will be updated as soon as the payment is confirmed.
Lemon Squeezy emails its own receipt to the customer. Since Lemon Squeezy is the merchant of record, that receipt is the tax invoice of the sale.
Security Checks
Each webhook must carry a valid X-Signature (HMAC-SHA256 of the request body with your signing secret), or it is refused.
Then an order only pays one of your orders when it matches the checkout your site created for it:
- it carries the payment reference of that checkout, signed with your site’s secret key;
- same store and same variant;
- same mode (a test order never pays anything while the site is live, and the other way round);
- same currency and same amount (before tax, or tax included when your store uses tax-inclusive prices), with no discount code.
A paid order that fails one of these checks is not accepted: the payment is kept aside with the status review and the reason is written to the
application log (storage/logs). Check the order in Lemon Squeezy and refund it there if needed.
Refunds
- From your admin panel: when a selling add-on offers a refund action (e.g. Stock Media purchases), the refund is sent to Lemon Squeezy through the API, in full or in part.
- From the Lemon Squeezy dashboard: refund the order in Store → Orders. The
order_refundedwebhook records it on your site; a fully refunded Shop order is marked as refunded.
Lemon Squeezy returns the money to the customer, including the tax it collected.
Reconciliation
Some payment methods are not paid instantly: Lemon Squeezy then reports the order as pending. Every hour, the scheduled command
lemonsqueezy:reconcile asks Lemon Squeezy again about these orders (last 14 days) and confirms the ones paid since. You can also run it by hand:
php artisan lemonsqueezy:reconcile
php artisan lemonsqueezy:reconcile --days=30
It makes no API call while no order is waiting.
Wallet Plans (Subscriptions)
With the Wallet add-on, members can subscribe to a plan that gives them credits every month, billed monthly or yearly. Lemon Squeezy can bill these plans with its subscriptions: the member subscribes on the Lemon Squeezy checkout, Lemon Squeezy charges the card at every renewal, and your site follows the subscription through the webhooks.
Setup
- In Store → Products, create a product, e.g. Membership, with Subscription pricing and two variants: one billed every month and one billed every year. Their prices do not matter: each subscription is created at the price of its plan, and Lemon Squeezy keeps that price for all its renewals. Do not add a free trial.
- Copy the ID of each variant into Admin → Lemon Squeezy → Wallet Plans. Leave a field empty to not bill that interval with Lemon Squeezy.
- Tick the subscription events in your webhook (see Webhook).
- Click Verify connection: it checks that each variant is a subscription billed at the right interval.
Lemon Squeezy is then offered on the subscription page of every paid plan in the store currency. When Stripe also bills the plans, the member picks one of the two. In Settings → Payment methods, unticking Lemon Squeezy for the Wallet also stops new subscriptions with it (running ones keep being billed).
Subscription Lifecycle
| On Lemon Squeezy | On your site |
|---|---|
First payment (subscription_payment_success, initial) | The plan starts and the first monthly credits are granted. The next ones are granted every month by the Wallet scheduler. |
| Renewal paid | The paid period is extended to the next renewal date. |
Renewal failed (subscription_payment_failed) | The plan is past due. Lemon Squeezy retries the payment; a later success makes it active again. |
| Cancelled (by the member on your site, or on Lemon Squeezy) | The plan runs until the end of the paid period, then ends. Cancelling from the Wallet dashboard cancels the Lemon Squeezy subscription through the API, and Resume undoes it. |
Expired (subscription_expired) | The plan ends and its remaining plan credits are removed. |
As for single payments, a subscription only starts when it matches the checkout your site created (signed reference, store, variant, mode) and its invoices match the plan price, currency and mode, with no discount. Otherwise it is held for review and the reason is written to the application log.
Testing
- Switch the Lemon Squeezy dashboard to Test mode and do the setup there (test API key, test webhook).
- Keep Test Mode on in the add-on settings.
- Buy something on your site with Lemon Squeezy and pay with a test card, e.g.
4242 4242 4242 4242, any future date and any CVC. - Check that you come back to the confirmation page and then to the success page, and that the order is paid.
In Settings → Webhooks, Lemon Squeezy lists every webhook it sent with your site’s answer, and can resend one.
Going Live
- Make sure your Lemon Squeezy store is activated for live payments.
- Switch the dashboard to live mode, then create a live API key and a live webhook (same URL, same events, a signing secret).
- If the payment product was created in test mode, copy it to live mode (product menu → Copy to live mode): the variant ID changes, use the new one.
- In the add-on settings, paste the live API key and signing secret, the live variant ID, turn Test Mode off, save and click Verify connection.
Updating
Method 1: Admin Panel Upload (Recommended)
- Download the latest
.zipfile of this add-on. - Go to Admin panel → Add-ons and click the Upload button.
- Select or drag the
.zipfile into the upload area. - A confirmation prompt will show the current and new version numbers. Click Replace to proceed.
- Go to Admin panel → System Update (
/admin/update) to apply any pending database migrations.
Method 2: Manual File Replacement
- Replace the
extensions/addons/lemonsqueezy/directory with the new version. - Run the pending migrations:
php artisan migrate(safe to repeat). - Clear the caches:
php artisan optimize:clear. - Visit Admin → Lemon Squeezy and click Verify connection.
Uninstallation
Switching an add-on off without losing anything is a deactivation: go to Admin panel → Add-ons, find Lemon Squeezy Payment Gateway and click Deactivate.
- Its routes, views, admin menu entries and permissions stop being registered, and its front-end pages stop answering.
- Its database tables and all the data they hold are kept, and its files stay under
extensions/addons/lemonsqueezy/. Nothing is deleted. - The purchase code recorded at activation is kept too, so activating the add-on again does not ask for it.
- Deactivation is refused while another active add-on depends on this one: deactivate that add-on first.
Click Activate on the same card to switch it back on. Pending migrations are re-run, assets are republished, and the add-on picks up exactly where it left off.
Removing
Removing is permanent and destroys the add-on's data. The Remove button only appears on a deactivated add-on, so removal is always two steps:
- Deactivate Lemon Squeezy Payment Gateway (see Uninstallation).
- Click Remove on its card and confirm the prompt.
The admin panel then, in one pass:
- runs the add-on's uninstall hook, if it ships one, while its code is still on disk;
- revokes the permissions declared in its
addon.json; - rolls back its migrations (this drops its database tables and every row they hold) and purges its entries from the
migrationstable, so a later reinstall migrates from scratch; - deletes its published assets:
public/addons/lemonsqueezy/,public/vendor/lemonsqueezy/andstorage/app/public/addons/lemonsqueezy/; - deletes the add-on directory
extensions/addons/lemonsqueezy/; - deletes its row in the
addonstable (the recorded purchase code goes with it) and clears the application cache.
Removal is refused, with an explanatory message and before anything is destroyed, when the add-on is still active, when another active add-on depends on it, or when the web server (PHP) user cannot delete extensions/addons/lemonsqueezy/. In that last case, give that user write permission on the directory and on its parent, then try again.
Deleting the folder over FTP or SSH is not equivalent: the add-on's tables, its entries in the migrations table and its addons row are all left behind, and its card stays in the list. Use Remove in the admin panel instead.
Troubleshooting
Lemon Squeezy is not offered at checkout
- The API key, the store ID, the variant ID and the webhook signing secret must all be set.
- Check Admin → Settings → Payment methods: Lemon Squeezy may be switched off for that add-on.
"Lemon Squeezy cannot charge ...: the store sells in ..."
The order is in another currency than your store. Use the store currency in the selling add-on, or set the right currency in the Payment Options tab if it is wrong there (Verify connection tells you the store currency).
The customer paid but the order stays unpaid
- In Lemon Squeezy, Settings → Webhooks, open your webhook: every call is listed with your site’s answer.
- No call at all: the webhook is missing, created in the other mode (test/live), or the
order_createdevent is not ticked. - Answer 400 “Invalid signature”: the signing secret differs between Lemon Squeezy and the add-on. Enter the same value in both, then resend the webhook.
- Answer 404 or 5xx: the callback URL is wrong, or your site is not reachable from the Internet (firewall, maintenance mode, basic authentication...).
- Answer 200 but still unpaid: the order did not match its checkout (see Security Checks). The reason is in the application log, as “Lemon Squeezy order does not match its checkout”.
The checkout cannot be created
The customer sees the error returned by Lemon Squeezy. The most common ones:
- Unauthenticated: the API key is wrong, revoked, or from the other mode.
- Not found / variant errors: the store or variant ID is wrong, or the product is not published, or it belongs to the other mode.
Click Verify connection in the settings to check all of them at once.
A member paid a plan but it is not active
- Check that the subscription events are ticked in the webhook (the first payment is
subscription_payment_success). - Look in the application log for “Lemon Squeezy subscription does not match its checkout”: the reason (store, variant, mode, currency, amount, discount) tells what differs.
Credentials appear empty after save
- Credentials are encrypted with the
APP_KEYof your site. If it changed, the stored values cannot be decrypted: enter them again.
Lemon Squeezy Payment Gateway v1.0.0: Part of the Larapen CMS platform.
© BeDigit. All rights reserved.