<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Thiago Oliveira</title>
    <description>The latest articles on DEV Community by Thiago Oliveira (@thiago_oliveira_fa0e40290).</description>
    <link>https://dev.to/thiago_oliveira_fa0e40290</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4114404%2F74a140f3-ea19-446b-a2cf-952433bc49a4.png</url>
      <title>DEV Community: Thiago Oliveira</title>
      <link>https://dev.to/thiago_oliveira_fa0e40290</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thiago_oliveira_fa0e40290"/>
    <language>en</language>
    <item>
      <title>How to Build a Stripe Failed-Payment Alert with n8n (Free Template)</title>
      <dc:creator>Thiago Oliveira</dc:creator>
      <pubDate>Mon, 07 Sep 2026 17:45:30 +0000</pubDate>
      <link>https://dev.to/thiago_oliveira_fa0e40290/how-to-build-a-stripe-failed-payment-alert-with-n8n-free-template-h4o</link>
      <guid>https://dev.to/thiago_oliveira_fa0e40290/how-to-build-a-stripe-failed-payment-alert-with-n8n-free-template-h4o</guid>
      <description>&lt;p&gt;Every subscription business loses a slice of MRR to payments that just... fail. A card expires, a bank flags a charge as suspicious, 3-D Secure times out. Stripe's dashboard shows you these failures if you go looking — but nobody goes looking until a customer emails asking why their account got downgraded.&lt;/p&gt;

&lt;p&gt;This post walks through a tiny n8n workflow that catches every failed Stripe payment and emails you about it the moment it happens. Three nodes, no dashboard, no monthly SaaS fee.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem in one sentence
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;invoice.payment_failed&lt;/code&gt; and &lt;code&gt;charge.failed&lt;/code&gt; are real-time Stripe webhook events. If nothing is listening for them, the only way you find out is by checking manually or waiting for a support ticket.&lt;/p&gt;

&lt;h2&gt;
  
  
  The workflow
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Webhook node&lt;/strong&gt; — listens for POST requests from Stripe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Code node&lt;/strong&gt; — normalizes the payload, since &lt;code&gt;invoice.payment_failed&lt;/code&gt; and &lt;code&gt;charge.failed&lt;/code&gt; have slightly different shapes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isInvoice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;invoice.payment_failed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;isInvoice&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;customer_email&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;billing_details&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;billing_details&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;amount_due&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;currency&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;currency&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;usd&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;declineReason&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;isInvoice&lt;/span&gt;
  &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;last_finalization_error&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;last_finalization_error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Card declined&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;failure_message&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Card declined&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;json&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;declineReason&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;eventType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. HTTP Request node&lt;/strong&gt; — POSTs to SendGrid (or Postmark/Resend/Mailgun — same pattern) with the customer, amount, and decline reason.&lt;/p&gt;

&lt;p&gt;That's the whole thing. Wire the Stripe webhook to point at this endpoint, subscribe to &lt;code&gt;invoice.payment_failed&lt;/code&gt; and &lt;code&gt;charge.failed&lt;/code&gt;, and you get a Slack-worthy alert the second a payment fails.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Import the workflow JSON (full file at the bottom of this post, or in the &lt;a href="https://community.n8n.io/" rel="noopener noreferrer"&gt;n8n community thread&lt;/a&gt; where I first shared it).&lt;/li&gt;
&lt;li&gt;In Stripe Dashboard → Developers → Webhooks, point an endpoint at the Webhook node's URL.&lt;/li&gt;
&lt;li&gt;Add a SendGrid API key as an HTTP Header Auth credential on the HTTP Request node.&lt;/li&gt;
&lt;li&gt;Activate.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Where I'd take this further
&lt;/h2&gt;

&lt;p&gt;This version only tells you about the failure — it doesn't do anything about it. The natural next step is a proper dunning sequence: email the &lt;em&gt;customer&lt;/em&gt; (not just yourself), retry on a schedule, escalate over a week, and stop automatically the moment they pay. That's a longer workflow (14 nodes vs. 3), and I built a version of it as a &lt;a href="https://gum.co/u/jto9ppxy" rel="noopener noreferrer"&gt;paid template&lt;/a&gt; if you want the done-for-you version — but the pattern above is the free, useful-on-its-own core of it.&lt;/p&gt;

&lt;p&gt;Happy to answer questions about the Stripe webhook shapes or the n8n setup in the comments.&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>automation</category>
      <category>stripe</category>
      <category>saas</category>
    </item>
  </channel>
</rss>
