Lemon Squeezy payment failed notifications on your phone.

Get a High-priority push notification when a Lemon Squeezy subscription renewal payment fails.

subscription_payment_failedFinanceSubscriptions
How it works

Three steps to your first push

STEP 01

Install the recipe

One click in Studio gives you a personal webhook URL.

STEP 02

Paste your URL into Lemon Squeezy

Add it as a webhook for subscription_payment_failed.

STEP 03

Get a push on your phone

With the text, sound and buttons from the recipe.

Setup

How to set up the Lemon Squeezy subscription_payment_failed webhook

  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 as the callback URL, enter a signing secret, and tick subscription_payment_failed.https://••••••••/•••••••• your personal URL, shown after install
  4. Save. Test mode and live mode have separate webhooks.
  5. Add a webhook under **Settings → Webhooks** with the URL above and tick `subscription_payment_failed`. Lemon Squeezy retries failed payments automatically.
  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.
The code

What runs when the webhook arrives

Studio calls handleRequest(request) with the incoming webhook and sends the message it returns. It's yours after install; change anything.

transform.js
1// Lemon Squeezy → subscription payment failed
2// Fires when a renewal payment fails. Lemon Squeezy retries it automatically.
3// Docs: https://docs.lemonsqueezy.com/help/webhooks/event-types
4
5// The event name comes in the X-Event-Name header and in meta.event_name.
6// Header names can arrive in any case.
7function header(request, name) {
8 const headers = request.headers || {}
9 const key = Object.keys(headers).find((k) => k.toLowerCase() === name)
10 const value = key ? headers[key] : null
11 return Array.isArray(value) ? value[0] : value
12}
13
14// Lemon Squeezy puts test_mode in meta on real deliveries and in the attributes in its examples.
15function testMode(body) {
16 return (body.meta?.test_mode ?? body.data?.attributes?.test_mode) === true ? " (test mode)" : ""
17}
18
19// Only link to real http(s) URLs.
20function link(url, cta) {
21 return typeof url === "string" && /^https?:\/\//.test(url) ? [{ cta, url }] : []
22}
23
24function handleRequest(request) {
25 const body = request.body || {}
26 const event = header(request, "x-event-name") ?? body.meta?.event_name
27 const order = body.data?.attributes ?? {}
28
29 // Guard: only subscription_payment_failed events.
30 if (event !== "subscription_payment_failed") {
31 console.log(`Ignoring Lemon Squeezy "${event ?? "unknown"}" event`)
32 return null
33 }
34
35 // Payment events carry a subscription invoice, not the subscription itself.
36 const invoice = order
37 const card = invoice.card_last_four ? ` (${invoice.card_brand ?? "card"} ••${invoice.card_last_four})` : ""
38
39 return {
40 title: "⚠️ Subscription payment failed",
41 message:
42 (invoice.total_formatted ?? "A renewal payment") +
43 (invoice.user_name ? ` from ${invoice.user_name}` : "") +
44 card +
45 testMode(body),
46 topic: "Lemon Squeezy",
47 priority: 1, // High — a paying customer is at risk of churning
48 buttons: link(invoice.urls?.invoice_url, "View invoice"),
49 }
50}
Payload

The Lemon Squeezy subscription_payment_failed webhook

This is what Lemon Squeezy sends to your URL for subscription_payment_failed. It is a sample, trimmed to the fields recipes use.

subscription_payment_failed · sample.json
1{
2 "data": {
3 "id": "88990",
4 "type": "subscription-invoices",
5 "attributes": {
6 "urls": {
7 "invoice_url": "https://app.lemonsqueezy.com/my-orders/invoice/88990?signature=abc"
8 },
9 "total": 1500,
10 "status": "failed",
11 "currency": "EUR",
12 "store_id": 12345,
13 "test_mode": false,
14 "user_name": "Jane Doe",
15 "card_brand": "visa",
16 "user_email": "[email protected]",
17 "billing_reason": "renewal",
18 "card_last_four": "4242",
19 "subscription_id": 33445,
20 "total_formatted": "€15.00",
21 "status_formatted": "Failed"
22 }
23 },
24 "meta": {
25 "test_mode": false,
26 "event_name": "subscription_payment_failed",
27 "webhook_id": "a1b2c3d4-e5f6-7a8b-9c0d-1e2f3a4b5c6d"
28 }
29}
FAQ

Lemon Squeezy payment failed notifications: questions

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.

Ready when you are

Lemon Squeezy on your phone in two minutes.

Install the recipe, paste one URL, done. Free for 30 days, no credit card required.