# Mollie payment failed notifications on your phone

> Get a High-priority push notification when a Mollie payment fails, including the card's decline reason when there is one.

- Company: Mollie (https://www.justpush.io/recipes/mollie)
- Event: `payment.failed` (payment.failed)
- Tags: Finance, Payments
- Install: https://studio.justpush.io/recipes/mollie/payment-failed
- Web page: https://www.justpush.io/recipes/mollie/payment-failed

## 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 Mollie Dashboard, go to Developers > Webhooks and create a new webhook.
3. Paste your webhook URL (shown in Studio after install) as the URL and select the payment.failed event.
4. Choose the full payload (so the payment details are included) and save.
5. This recipe needs a **next-gen** webhook (Developers > Webhooks), set to send the **full payload**. Classic webhooks (the `webhookUrl` you pass when creating a payment) only send the payment ID, so they can't produce a useful notification.
6. Mollie signs next-gen webhooks with an `X-Mollie-Signature` header, 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
// Mollie → payment.failed
// Fires when a payment fails (for example, a declined card).
// Docs: https://docs.mollie.com/reference/webhooks-new
//
// Needs a next-gen Mollie webhook (Developers > Webhooks) for the "payment.failed" event,
// set to send the full payload, pointing at the integration's endpoint URL.

// Mollie amounts are objects with a decimal string: { value: "10.00", currency: "EUR" }.
// Returns null when there's no amount.
function money(amount) {
    const value = Number(amount?.value)

    if (amount?.value == null || !Number.isFinite(value) || !amount.currency) return null

    try {
        return new Intl.NumberFormat("en-GB", { style: "currency", currency: amount.currency }).format(value)
    } catch {
        return `${amount.value} ${amount.currency}`
    }
}

// Friendlier names for Mollie's payment method IDs.
const METHODS = {
    ideal: "iDEAL",
    creditcard: "card",
    bancontact: "Bancontact",
    paypal: "PayPal",
    applepay: "Apple Pay",
    banktransfer: "bank transfer",
    directdebit: "direct debit",
    klarna: "Klarna",
    in3: "iDEAL in3",
    twint: "TWINT",
    blik: "BLIK",
    przelewy24: "Przelewy24",
    eps: "EPS",
}

function handleRequest(request) {
    const event = request.body

    // Guard: only handle this event type, so other Mollie events on this integration stay quiet.
    if (event?.resource !== "event" || event.type !== "payment.failed") {
        console.log(`Ignoring Mollie event "${event?.type ?? "unknown"}"`)
        return null
    }

    // Next-gen webhooks only include the object when "full payload" is chosen.
    const entity = event._embedded?.entity

    if (!entity) {
        console.log("No embedded entity — set the webhook to send the full payload")
        return null
    }

    const method = entity.method ? ` via ${METHODS[entity.method] ?? entity.method}` : ""
    const who = entity.details?.consumerName ?? entity.details?.cardHolder
    const test = entity.mode === "test" ? " (test mode)" : ""
    const dashboard = entity._links?.dashboard?.href
    // Card payments explain why they failed; other methods usually don't.
    const reason = entity.details?.failureMessage ?? entity.details?.failureReason?.replace(/_/g, " ")

    return {
        title: "🚫 Payment failed",
        message:
            (money(entity.amount) ?? "A payment") +
            method +
            (who ? ` from ${who}` : "") +
            (entity.description ? ` — ${entity.description}` : "") +
            (reason ? `. ${reason}` : "") +
            test,
        topic: "Mollie",
        priority: 1, // High — a customer tried to pay and couldn't
        buttons: dashboard ? [{ cta: "View payment", url: dashboard }] : [],
    }
}
```

## Mollie payment.failed webhook payload (sample)

```json
{
  "id": "event_GvJ8WHrp5isUdRub9CJyH",
  "type": "payment.failed",
  "_links": {
    "documentation": {
      "href": "https://docs.mollie.com/reference/webhooks-new",
      "type": "text/html"
    }
  },
  "entityId": "tr_WDqYK6vllg",
  "resource": "event",
  "_embedded": {
    "entity": {
      "id": "tr_WDqYK6vllg",
      "mode": "live",
      "_links": {
        "dashboard": {
          "href": "https://my.mollie.com/dashboard/org_12345678/payments/tr_WDqYK6vllg",
          "type": "text/html"
        }
      },
      "amount": {
        "value": "129.00",
        "currency": "EUR"
      },
      "method": "creditcard",
      "status": "failed",
      "details": {
        "cardLabel": "Mastercard",
        "cardHolder": "Jane Doe",
        "cardNumber": "6787",
        "failureReason": "insufficient_funds",
        "failureMessage": "The card has insufficient funds.",
        "cardCountryCode": "NL"
      },
      "failedAt": "2026-09-28T09:29:47+00:00",
      "resource": "payment",
      "createdAt": "2026-09-28T09:28:11+00:00",
      "profileId": "pfl_QkEhN94Ba",
      "description": "Order #12346"
    }
  },
  "createdAt": "2026-09-28T09:29:48.0Z"
}
```

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