RevenueCat refund notifications on your phone.

Get a push notification when an App Store, Google Play or other purchase tracked by RevenueCat is refunded.

CANCELLATIONFinancePayments
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 RevenueCat

Add it as a webhook for CANCELLATION.

STEP 03

Get a push on your phone

With the text, sound and buttons from the recipe.

Setup

How to set up the RevenueCat cancellation 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 the RevenueCat dashboard, open your project's Integrations > Webhooks and add a new webhook.
  3. Paste your webhook URL as the webhook URL.https://••••••••/•••••••• your personal URL, shown after install
  4. Send all events, or only CANCELLATION; the recipe ignores every other event type.
  5. Save, then click Send test event to confirm it arrives.
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// RevenueCat → CANCELLATION (refunds)
2// Fires when a purchase is refunded (RevenueCat sends these as CANCELLATION with cancel_reason CUSTOMER_SUPPORT).
3// Docs: https://www.revenuecat.com/docs/integrations/webhooks/event-types-and-fields
4//
5// Paste this into a JustPush Studio integration and add a RevenueCat webhook pointing
6// at the integration's endpoint URL.
7
8// Human-readable store names.
9const STORES = {
10 APP_STORE: "App Store",
11 MAC_APP_STORE: "Mac App Store",
12 PLAY_STORE: "Google Play",
13 AMAZON: "Amazon",
14 STRIPE: "Stripe",
15 PADDLE: "Paddle",
16 RC_BILLING: "Web Billing",
17 ROKU: "Roku",
18 PROMOTIONAL: "a promotional grant",
19 TEST_STORE: "Test Store",
20}
21
22// RevenueCat prices are decimals ("9.99"), not cents. Returns null when there's no price.
23function money(amount, currency) {
24 const value = Number(amount)
25
26 if (amount == null || !Number.isFinite(value) || !currency) return null
27
28 try {
29 return new Intl.NumberFormat("en-GB", { style: "currency", currency }).format(value)
30 } catch {
31 return `${value} ${currency}`
32 }
33}
34
35// Turn "NL" into 🇳🇱.
36function flag(countryCode) {
37 return /^[A-Z]{2}$/.test(countryCode ?? "")
38 ? String.fromCodePoint(...[...countryCode].map((c) => 127397 + c.charCodeAt(0)))
39 : ""
40}
41
42// "pro_monthly on App Store from [email protected] 🇳🇱 (sandbox)"
43function where(event) {
44 const attributes = event.subscriber_attributes ?? {}
45 const who = attributes.$email?.value ?? attributes.$displayName?.value
46 const store = STORES[event.store] ?? event.store
47
48 return (
49 (event.product_id ?? "a product") +
50 (store ? ` on ${store}` : "") +
51 (who ? ` from ${who}` : "") +
52 (flag(event.country_code) ? ` ${flag(event.country_code)}` : "") +
53 (event.environment === "SANDBOX" ? " (sandbox)" : "")
54 )
55}
56
57function handleRequest(request) {
58 const event = (request.body || {}).event
59
60 // "Send test event" in RevenueCat; confirm the connection with a quiet push.
61 if (event?.type === "TEST") {
62 return { title: "🔔 RevenueCat connected", message: "Test event received", topic: "RevenueCat", priority: -1 }
63 }
64
65 // Guard: only handle this event type, so other RevenueCat events on this integration stay quiet.
66 if (event?.type !== "CANCELLATION") {
67 console.log(`Ignoring RevenueCat event "${event?.type ?? "unknown"}"`)
68 return null
69 }
70
71 // Only refunds; regular cancellations are handled by the cancellation recipe.
72 if (event.cancel_reason !== "CUSTOMER_SUPPORT") {
73 console.log(`Skipping "${event.cancel_reason ?? "unknown"}" cancellation — not a refund`)
74 return null
75 }
76
77 // Refund prices are negative; show the refunded amount as a positive figure.
78 const amount = event.price_in_purchased_currency
79 const refunded = amount == null ? null : money(Math.abs(Number(amount)), event.currency)
80
81 return {
82 title: "↩️ Refund",
83 message: (refunded ? `${refunded} refunded for ` : "Refund for ") + where(event),
84 topic: "RevenueCat",
85 priority: 0, // Normal — app store refunds happen without you, so it's worth knowing
86 }
87}
Payload

The RevenueCat CANCELLATION webhook

This is what RevenueCat sends to your URL for cancellation. It is a sample, trimmed to the fields recipes use.

CANCELLATION · sample.json
1{
2 "event": {
3 "id": "CD489E0E-REFUND",
4 "type": "CANCELLATION",
5 "price": -10.87,
6 "store": "APP_STORE",
7 "app_id": "app1a2b3c4d5",
8 "aliases": [
9 "user_8Hq2"
10 ],
11 "currency": "EUR",
12 "product_id": "pro_monthly",
13 "app_user_id": "user_8Hq2",
14 "environment": "PRODUCTION",
15 "period_type": "NORMAL",
16 "country_code": "NL",
17 "cancel_reason": "CUSTOMER_SUPPORT",
18 "transaction_id": "2000000712345678",
19 "entitlement_ids": [
20 "pro"
21 ],
22 "purchased_at_ms": 1790584200000,
23 "expiration_at_ms": 1793176200000,
24 "event_timestamp_ms": 1790584200000,
25 "subscriber_attributes": {
26 "$email": {
27 "value": "[email protected]",
28 "updated_at_ms": 1790584100000
29 }
30 },
31 "original_transaction_id": "2000000612345678",
32 "price_in_purchased_currency": -9.99
33 },
34 "api_version": "1.0"
35}
FAQ

RevenueCat refund 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 RevenueCat 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

RevenueCat on your phone in two minutes.

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