# LemonSqueezy

Source: https://kart.bnomei.com/docs/providers/lemonsqueezy
Updated: 2025-08-08T14:19:27+00:00
Summary: LemonSqueezy provider for Kirby CMS Kart plugin: sell single products via buy-now checkouts. Configure in config.php, set API keys & customize checkouts.

> This provider is limited to fetching products from LemonSqueezy.   
> It can not do checkouts from carts with multiple items.  
> You can only sell a single item at once.  
> It can create orders in Kirby.

## Checkouts

Since you can only sell one product at a time, you can either redirect your customers to the product page hosted by Lemonsqueezy or stick with the *buy now* feature of the Kart plugin. The latter provides a nicer user experience as it sends them to an already initiated checkout page hosted by LemonSqueezy, ready to accept the payment information.

Path: site/templates/product.php  
Code (php):  
```
<?php
/** @var ProductPage $page */
$product ??= $page;

if ($product->inStock()) { ?>
    <form method="POST" action="<?= $product->buy() ?>">
        <input type="hidden" name="redirect" value="<?= $redirect ?? $page->url() ?>">
        <button type="submit" onclick="this.disabled=true;this.form.submit();">Buy now</button>
    </form>
<?php } else { ?>
    <p><mark>out of stock</mark></p>
<?php }
```

  
## Using the provider

Path: site/config/config.php  
Code (php):  
```
<?php

return [
   'bnomei.kart.provider' => 'lemonsqueezy',
   // other options
];
```

  
## Virtual Fields

You can define which fields are treated as purely virtual and fetched from the provider ignoring any changes you make within the panel.

Code (php):  
```
<?php

return [
 'bnomei.kart.providers.lemonsqueezy.virtual' => true,
 // 'bnomei.kart.providers.lemonsqueezy.virtual' => ['raw', 'description', 'gallery', 'price', 'variants', 'title'],

 // other options
];
```

  
## API Credentials

![](https://kart.bnomei.com/media/pages/media/f95d83e347-1746706067/lemonsqueeze-1920x.webp)  
Path: .env  
Code (plaintext):  
```
LEMONSQUEEZY_STORE_ID=XXX
LEMONSQUEEZY_SECRET_KEY=ZZZ
```

  
## Customzing the Checkout

You can use a callback to customise both the checkout process. The returned arrays from your callbacks will be merged with the defaults created by the plugin for this provider, allowing you to override those defaults. Check the relevant PHP class and the linked online documentation for the provider to learn more about the expected data structure.

Code (php):  
```
<?php

return [
    'bnomei.kart.providers.lemonsqueezy.checkout_options' => function (\Bnomei\Kart\Kart $kart) {
        // configure the checkout based on current kart instance
        // https://docs.lemonsqueezy.com/api/checkouts/create-checkout
        return [];
    },
    // other options
];
```

  