# Lemon Squeezy new order notifications on your phone

> Get a push notification with the amount, customer and product every time a Lemon Squeezy order comes in.

- Company: Lemon Squeezy (https://www.justpush.io/recipes/lemonsqueezy)
- Event: `order_created` (order_created)
- Tags: Finance, Payments
- Install: https://studio.justpush.io/recipes/lemonsqueezy/order-created
- Web page: https://www.justpush.io/recipes/lemonsqueezy/order-created

## Setup

1. Click Install in Studio and sign in. The recipe is added to your account and you get a personal webhook URL.
2. In Lemon Squeezy, go to Settings > Webhooks and add a webhook.
3. Paste your webhook URL (shown in Studio after install) as the callback URL, enter a signing secret, and tick order_created.
4. Save. Test mode and live mode have separate webhooks.
5. Add a webhook under **Settings → Webhooks** with the URL above and tick `order_created`. The first payment of a subscription is also an order, so if you use the [new subscriber](../subscription-created) recipe too, you'll get both pushes for a new subscription.
6. Lemon Squeezy signs deliveries with `X-Signature` (HMAC-SHA256 of your signing secret), but JustPush doesn't check it yet, so keep your endpoint URL private.

## Code

Studio calls `handleRequest(request)` with the incoming webhook (`{ method, headers, body, query, raw }`) and sends the message object it returns. Returning `null` sends nothing.

```js
// Lemon Squeezy → order created
// Fires for every new order, including the first payment of a subscription.
// Docs: https://docs.lemonsqueezy.com/help/webhooks/event-types

// The event name comes in the X-Event-Name header and in meta.event_name.
// Header names can arrive in any case.
function header(request, name) {
    const headers = request.headers || {}
    const key = Object.keys(headers).find((k) => k.toLowerCase() === name)
    const value = key ? headers[key] : null
    return Array.isArray(value) ? value[0] : value
}

// Lemon Squeezy puts test_mode in meta on real deliveries and in the attributes in its examples.
function testMode(body) {
    return (body.meta?.test_mode ?? body.data?.attributes?.test_mode) === true ? " (test mode)" : ""
}

// Only link to real http(s) URLs.
function link(url, cta) {
    return typeof url === "string" && /^https?:\/\//.test(url) ? [{ cta, url }] : []
}

function handleRequest(request) {
    const body = request.body || {}
    const event = header(request, "x-event-name") ?? body.meta?.event_name
    const order = body.data?.attributes ?? {}

    // Guard: only order_created events.
    if (event !== "order_created") {
        console.log(`Ignoring Lemon Squeezy "${event ?? "unknown"}" event`)
        return null
    }

    const item = order.first_order_item ?? {}
    const product = [item.product_name, item.variant_name && item.variant_name !== "Default" ? item.variant_name : null].filter(Boolean).join(" — ")
    const pending = order.status && order.status !== "paid" ? ` (${order.status_formatted ?? order.status})` : ""

    return {
        title: `💰 New order #${order.order_number ?? body.data?.id ?? ""}${pending}`.replace(/#\s|#$/, ""),
        message:
            (order.total_formatted ?? "A new order") +
            (order.user_name ? ` from ${order.user_name}` : "") +
            (product ? ` — ${product}` : "") +
            testMode(body),
        topic: "Lemon Squeezy",
        priority: 0, // Normal — money in is good news, not an emergency
        sound: "cashregister",
        buttons: link(order.urls?.receipt, "View receipt"),
    }
}
```

## Lemon Squeezy order_created webhook payload (sample)

```json
{
  "data": {
    "id": "1234567",
    "type": "orders",
    "attributes": {
      "tax": 1029,
      "urls": {
        "receipt": "https://app.lemonsqueezy.com/my-orders/104e18a2-d755-4d4b-80c4-a6c1dcbe1c10?signature=abc"
      },
      "total": 5929,
      "status": "paid",
      "currency": "EUR",
      "refunded": false,
      "store_id": 12345,
      "subtotal": 4900,
      "test_mode": false,
      "user_name": "Jane Doe",
      "created_at": "2026-09-29T09:45:53.000000Z",
      "user_email": "jane@example.com",
      "refunded_at": null,
      "order_number": 1042,
      "total_formatted": "€59.29",
      "first_order_item": {
        "price": 4900,
        "test_mode": false,
        "product_name": "Acme Pro",
        "variant_name": "Yearly"
      },
      "status_formatted": "Paid"
    }
  },
  "meta": {
    "test_mode": false,
    "event_name": "order_created",
    "webhook_id": "a1b2c3d4-e5f6-7a8b-9c0d-1e2f3a4b5c6d"
  }
}
```

## FAQ

### Does this work on iPhone and Android?

Yes. Install the JustPush app from the App Store or Google Play and sign in. Every phone signed in to your account gets the notification.

### Do I need to write code?

No. Install the recipe in Studio, paste your webhook URL into Lemon Squeezy and you are done. The code is there if you want to change the text, the sound or the buttons.

### Can I change what the notification says?

Yes. After install the recipe's code is yours. Edit it in Studio and test it against the sample payload before you save.

### What does it cost?

JustPush is free for 30 days. After that it's $19.99 a year, or $39.99 once. There is no extra charge for recipes.
