# Lemon Squeezy

:::tip Available
This integration is active and ready to use in Frihet.
:::

Connect your Lemon Squeezy store to Frihet. Import digital software products and orders, automatically record revenue, and keep all your invoicing centralized. Lemon Squeezy acts as the Merchant of Record (manages taxes for you) and Frihet records the transactions for your accounting.

## Purpose

With Lemon Squeezy integrated:

- **Import products** — Bring your catalog of software and digital products into Frihet
- **Import orders** — Each sale is recorded as revenue in your ERP
- **Automatic deduplication** — Already imported orders are not duplicated (prefix `LS-`)
- **Multi-store** — If you have multiple stores, select which one to import from or import from all
- **Simplified tax management** — Lemon Squeezy handles taxes as MoR; Frihet records the net amounts
- **Subscriptions** — Tracking recurring SaaS payments

## Requirements

- **Active Lemon Squeezy account** — [lemonsqueezy.com](https://www.lemonsqueezy.com)
- **API Key** — Generated from the dashboard
- **Frihet Pro or higher**

## Connect Lemon Squeezy with Frihet

### Step 1: Get your API Key

1. Go to [app.lemonsqueezy.com/settings/api](https://app.lemonsqueezy.com/settings/api)
2. Log in to your account
3. Click on **Create API key** (or the "+" button)
4. Give it a name (e.g., "Frihet ERP")
5. Copy the generated API Key

:::caution Save the key
The API Key is only shown once when created. Copy it before closing the window.
:::

### Step 2: Configure in Frihet

1. Go to **Settings** → **Integrations**
2. Find **Lemon Squeezy**
3. Click on **Connect**
4. Paste your **API Key**
5. Click on **Verify connection**
6. If successful, Frihet will load your available stores
7. **(Optional)** Select a **specific store** from the dropdown — if you don't select any, products and orders from all your stores will be imported
8. Click on **Save connection**

### Step 3: Verify connection

1. Frihet will display a summary of your store:
   - Store name
   - Number of products
   - Recent orders
2. Perform a test import

## How it works

Frihet uses the Lemon Squeezy API with **JSON:API** format:

1. You provide your API Key
2. Frihet sends the key in the `Authorization: Bearer <api-key>` header
3. Responses follow the JSON:API format (with `data`, `attributes`, `relationships`)
4. Products and orders are imported on demand
5. Deduplication is based on the Lemon Squeezy order ID (prefix `LS-{id}`)
6. The API Key is stored encrypted (AES-256-GCM) in Frihet

## Synchronized Data

| Data | Direction | Frequency |
|------|-----------|------------|
| Products | Lemon Squeezy → Frihet | On demand |
| Orders | Lemon Squeezy → Frihet | On demand |
| Buyer data | Lemon Squeezy → Frihet | With each order |
| Amount and currency | Lemon Squeezy → Frihet | With each order |
| Order status | Lemon Squeezy → Frihet | With each import |

## Merchant of Record

Lemon Squeezy acts as the **Merchant of Record**, which means that:

- **Lemon Squeezy** charges the client, manages VAT/Sales Tax, and issues the invoice to the buyer
- **You receive** the net amount (after taxes and commissions)
- **Frihet records** the net revenue you receive for your internal accounting

This simplifies your accounting: you don't need to calculate international taxes for each digital sale.

## Use Cases

### Indie Developer with SaaS

You sell licenses for your software through Lemon Squeezy. Each payment is imported into Frihet as revenue, including both one-time payments and subscription renewals.

### Plugin or Theme Creator

You sell WordPress plugins, Shopify themes, or extensions. Frihet consolidates this revenue with the rest of your invoicing (consulting services, other clients).

### Subscription Tracking

You have a SaaS product with monthly and annual plans. From Frihet, you can see the breakdown of recurring revenue imported from Lemon Squeezy along with the rest of your business.

## Import products

1. Go to **Settings** → **Integrations** → **Lemon Squeezy**
2. Click on **Import products**
3. Frihet will fetch the products from your store

Data imported per product:
- Name
- Price
- Type (one-time payment, subscription)
- Status (published, draft)

## Import orders

1. Go to **Settings** → **Integrations** → **Lemon Squeezy**
2. Click on **Import orders**
3. Select the date range
4. Frihet will create revenue records for each order

Each imported order includes:
- Order ID
- Buyer name and email
- Product purchased
- Total and net amount
- Currency
- Order date
- Status (completed, refunded, pending)

### Automatic retries

If an import fails due to a temporary error (timeout, server error), Frihet automatically retries up to 3 times with exponential waits (1s, 2s, 4s). You don't need to do anything — retries are transparent.

## Troubleshooting

### "Authentication error"

- Verify that the API Key is correct and has not been revoked
- Check that your Lemon Squeezy account is active
- If you created a new API Key, update it in Frihet

### "Orders are not imported"

- Check that you have orders in the selected date range
- Verify that the API Key is not restricted to certain scopes
- If your store is new, ensure there is at least one completed order

### "Amounts do not match what I see in Lemon Squeezy"

- Frihet imports the amount you receive (net of taxes and Lemon Squeezy commissions)
- The gross amount the buyer sees includes taxes managed by the MoR
- Consult the breakdown in your Lemon Squeezy dashboard to confirm

### "I want to disconnect"

1. Go to **Settings** → **Integrations** → **Lemon Squeezy**
2. Click on **Disconnect**
3. Optionally, revoke the API Key from your Lemon Squeezy dashboard

## Next steps

- [Connect Gumroad for more digital sales](./gumroad)
- [Connect Stripe for card payments](./stripe)
- [Automate imports with n8n](./n8n)
