# Stripe trial ending soon notifications on your phone > Get a heads-up three days before a Stripe subscription's free trial ends. - Company: Stripe (https://www.justpush.io/recipes/stripe) - Event: `customer.subscription.trial_will_end` (customer.subscription.trial_will_end) - Tags: Finance, Subscriptions - Install: https://studio.justpush.io/recipes/stripe/trial-ending - Web page: https://www.justpush.io/recipes/stripe/trial-ending ## 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 the Stripe Dashboard, open Workbench > Webhooks and click Add destination. 3. Select the customer.subscription.trial_will_end event and choose Webhook endpoint. 4. Paste your webhook URL (shown in Studio after install) as the endpoint URL and save. 5. Reveal the signing secret (whsec_…) and copy it into JustPush. ## 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 // Stripe → customer.subscription.trial_will_end // Fires when a trial is three days from ending. // Docs: https://docs.stripe.com/api/events/types // // Paste this into a JustPush Studio integration and add a Stripe webhook destination // for the "customer.subscription.trial_will_end" event pointing at the integration's endpoint URL. // Stripe amounts are in the currency's smallest unit (cents), 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 event doesn't carry one. if (typeof amount !== "number" || !Number.isFinite(amount) || !currency) return null const code = String(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()}` } } // Test-mode objects live under /test in the Dashboard. function dashboardUrl(event, path) { return `https://dashboard.stripe.com/${event.livemode ? "" : "test/"}${path}` } // Stripe timestamps are seconds since epoch. function day(seconds) { return new Date(seconds * 1000).toLocaleDateString("en-GB", { day: "numeric", month: "short", timeZone: "UTC", }) } // Describe the first subscription item, e.g. "Pro — £20.00/month". // Stripe only sends the product ID, so the price's nickname is the best name available. function plan(subscription) { const item = subscription.items?.data?.[0] const price = item?.price if (!price) return null const recurring = price.recurring const every = !recurring ? "" : recurring.interval_count > 1 ? ` every ${recurring.interval_count} ${recurring.interval}s` : `/${recurring.interval}` const each = money(price.unit_amount * (item.quantity ?? 1), price.currency) const cost = each ? each + every : null return [price.nickname, cost].filter(Boolean).join(" — ") || null } function handleRequest(request) { const event = request.body // Guard: only handle this event type, so other Stripe events on this integration stay quiet. if (event?.object !== "event" || event.type !== "customer.subscription.trial_will_end" || !event.data?.object) { console.log(`Ignoring Stripe event "${event?.type ?? "unknown"}"`) return null } const subscription = event.data.object const summary = plan(subscription) ?? "A subscription" const ends = subscription.trial_end ? ` on ${day(subscription.trial_end)}` : " soon" return { title: "⏳ Trial ending soon", message: `${summary} trial ends${ends}`, topic: "Stripe", priority: -1, // Low — a heads-up in case you want to reach out buttons: [ { cta: "View subscription", url: dashboardUrl(event, `subscriptions/${subscription.id}`) }, ], } } ``` ## Stripe customer.subscription.trial_will_end webhook payload (sample) ```json { "id": "evt_test_trial_ending", "data": { "object": { "id": "sub_test_1Qa2Bc", "items": { "data": [ { "id": "si_test_Q1a2", "price": { "id": "price_test_1Pro", "object": "price", "product": "prod_test_Pro", "currency": "eur", "nickname": "Pro", "recurring": { "interval": "month", "interval_count": 1 }, "unit_amount": 2000 }, "object": "subscription_item", "quantity": 1 } ], "object": "list" }, "object": "subscription", "status": "trialing", "customer": "cus_test_R2d2", "trial_end": 1790843400 } }, "type": "customer.subscription.trial_will_end", "object": "event", "created": 1790584200, "livemode": false, "api_version": "2025-09-30.clover" } ``` ## Signature check Stripe signs every webhook with a timestamped HMAC-SHA256 signature in the Stripe-Signature header, made with your endpoint's signing secret. JustPush checks it before the code runs. ## 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 Stripe 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.