# Ghost paid member notifications on your phone

> Get a push notification when a Ghost member becomes a paying member, with their tier and price.

- Company: Ghost (https://www.justpush.io/recipes/ghost)
- Event: `member.edited` (Member updated)
- Tags: Websites & CMS, Payments, Subscriptions
- Install: https://studio.justpush.io/recipes/ghost/paid-member
- Web page: https://www.justpush.io/recipes/ghost/paid-member

## 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 Ghost Admin, go to Settings > Advanced > Integrations and click Add custom integration (name it JustPush).
3. Click Add webhook, pick Member updated as the event and paste your webhook URL (shown in Studio after install) as the target URL.
4. Leave the secret empty (JustPush doesn't check it yet) and save.
5. Add **two** webhooks to the same custom integration, both pointing at your endpoint URL:
6. **Member updated**: catches free members who upgrade (the usual case).
7. **Member added**: catches members who are paid from the moment they're created.
8. Every other member change (name, labels, newsletters, …) is ignored.
9. To get a **View member** button that opens the member in Ghost Admin, add your site's address to the target URL:
10. ```
11. your webhook URL (shown in Studio after install)?site=https://yoursite.com
12. ```
13. Ghost can sign webhooks with a secret (`X-Ghost-Signature`), but JustPush doesn't check that signature yet, so leave the secret empty and 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
// Ghost → member.edited (member became paid)
// Fires when a Ghost member's status changes to "paid": a free member upgrades, or a
// new member signs up through Stripe checkout. Also accepts member.added for a member
// who is paid from the start.
// Docs: https://docs.ghost.org/webhooks

// Stripe (and so Ghost) amounts are in the currency's smallest unit, except for
// zero-decimal currencies such as JPY, where 500 means ¥500.
const ZERO_DECIMAL = new Set([
    "bif", "clp", "djf", "gnf", "jpy", "kmf", "krw", "mga",
    "pyg", "rwf", "ugx", "vnd", "vuv", "xaf", "xof", "xpf",
])

function money(amount, currency) {
    // Don't invent a figure when the subscription doesn't carry one.
    if (typeof amount !== "number" || !Number.isFinite(amount) || typeof currency !== "string" || !currency) return null
    const code = currency.toLowerCase()
    const value = ZERO_DECIMAL.has(code) ? amount : amount / 100
    try {
        return new Intl.NumberFormat("en-GB", { style: "currency", currency: code }).format(value)
    } catch {
        return `${value} ${code.toUpperCase()}`
    }
}

// Ghost sends plain strings; treat blanks as missing.
function text(value) {
    return typeof value === "string" && value.trim() ? value.trim() : null
}

// 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 && typeof request.body === "object" ? request.body : {}
    const member = body.member?.current
    const previous = body.member?.previous && typeof body.member.previous === "object" ? body.member.previous : null

    if (!member || typeof member !== "object" || !previous || (body.event && !/^member\.(added|edited)$/.test(body.event))) {
        console.log(`Ignoring Ghost "${body.event ?? "unknown"}" event`)
        return null
    }

    // "previous" only holds the fields that changed, so an upgrade shows up as previous.status.
    // A brand-new member has an empty "previous".
    const isNew = body.event ? body.event === "member.added" : Object.keys(previous).length === 0
    const upgraded = typeof previous.status === "string" && previous.status !== "paid"
    if (member.status !== "paid" || !(isNew || upgraded)) {
        console.log(`Skipping member change (status ${previous.status ?? "unchanged"} → ${member.status ?? "unknown"})`)
        return null
    }

    const name = text(member.name)
    const email = text(member.email)
    const who = name && email ? `${name} (${email})` : name || email || "A member"

    // The newest active subscription says what they pay.
    const subs = Array.isArray(member.subscriptions) ? member.subscriptions.filter((s) => s && typeof s === "object") : []
    const sub = subs.find((s) => s.status === "active" || s.status === "trialing") ?? subs[0]
    const tier = text(sub?.tier?.name) ?? text(sub?.price?.tier?.name) ?? (Array.isArray(member.tiers) ? text(member.tiers[0]?.name) : null)
    const price = money(sub?.price?.amount, sub?.price?.currency)
    const interval = text(sub?.price?.interval)
    const plan = [tier, price ? price + (interval ? `/${interval}` : "") : null].filter(Boolean).join(", ")
    const trial = sub?.status === "trialing" ? " (free trial)" : ""
    // ?site=https://yoursite.com adds a button to the member in Ghost Admin.
    const site = text(request.query?.site)?.replace(/\/+$/, "")

    return {
        title: "💰 New paid member",
        message: `${who} ${!upgraded ? "joined" : previous.status === "free" ? "upgraded" : "switched to paid"}` + (plan ? ` — ${plan}` : "") + trial,
        topic: "Ghost",
        priority: 0, // Normal — recurring revenue, worth a smile
        sound: "cashregister",
        buttons: site && member.id ? link(`${site}/ghost/#/members/${member.id}`, "View member") : [],
    }
}
```

## Ghost member.edited webhook payload (sample)

```json
{
  "event": "member.edited",
  "member": {
    "current": {
      "id": "623199bfe8bc4d3097caefe0",
      "name": "Jamie",
      "uuid": "4fa3e4df-85d5-44bd-b0bf-d504bbe22060",
      "email": "jamie@example.com",
      "tiers": [
        {
          "id": "62307cc71b4376a976734038",
          "name": "Supporter",
          "slug": "supporter",
          "type": "paid"
        }
      ],
      "comped": false,
      "labels": [],
      "status": "paid",
      "created_at": "2026-03-16T08:03:11.000Z",
      "subscribed": true,
      "updated_at": "2026-09-29T07:57:58.000Z",
      "subscriptions": [
        {
          "id": "sub_000000000000000000000000",
          "tier": {
            "id": "62307cc71b4376a976734038",
            "name": "Supporter",
            "slug": "supporter",
            "type": "paid",
            "currency": "USD",
            "yearly_price": 5000,
            "monthly_price": 500
          },
          "offer": null,
          "price": {
            "id": "price_000000000000000000000000",
            "tier": {
              "id": "prod_00000000000000",
              "name": "Supporter",
              "tier_id": "62307cc71b4376a976734038"
            },
            "type": "recurring",
            "amount": 500,
            "currency": "USD",
            "interval": "month",
            "nickname": "Monthly",
            "price_id": "6239692c664a9e6f5e5e840a"
          },
          "status": "active",
          "customer": {
            "id": "cus_00000000000000",
            "name": "Jamie",
            "email": "jamie@example.com"
          },
          "start_date": "2026-09-29T07:57:58.000Z",
          "trial_end_at": null,
          "trial_start_at": null,
          "current_period_end": "2026-10-29T07:57:58.000Z",
          "cancellation_reason": null,
          "cancel_at_period_end": false,
          "default_payment_card_last4": "4242"
        }
      ]
    },
    "previous": {
      "status": "free",
      "updated_at": "2026-03-16T08:03:40.000Z"
    }
  }
}
```

## 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 Ghost 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.
