🧾 Handle retail payment failures with retry emails, Slack alerts and Supabase logging

⚑ 27 views · 🧾 Invoice Processing

Description

Retail Payment Failure Alerts with Retry Emails, Slack & Supabase

This n8n workflow automatically handles failed payment events from payment gateways such as Stripe, Shopify, PayPal or WooCommerce. It receives payment failure webhooks, standardizes the incoming data, identifies the reason for failure and classifies each case into:

Based on the classification, the workflow automatically:

It helps businesses recover lost revenue, reduce manual payment support work and detect suspicious transactions early.

Quick Implementation Steps

  1. Import this JSON workflow into your n8n account.
  2. Connect your payment provider webhook endpoint.
  3. Add Slack API credentials.
  4. Add Gmail credentials for customer retry emails.
  5. Add Supabase credentials for failure logging.
  6. Enable the workflow β€” done!

What It Does

  1. Receives Payment Failure Events

    • Accepts POST webhook requests when a payment fails.
    • Supports providers such as Stripe, Shopify, PayPal, WooCommerce or custom gateways.
  2. Normalizes Payment Data

    • Extracts consistent fields such as:
      • order_id
      • customer_email
      • customer_name
      • order_value
      • currency
      • failure_reason
      • retry_url
  3. Classifies Failure Type

    • Soft Failure β†’ insufficient funds, timeout, temporary processor issues
    • Hard Failure β†’ expired card, invalid card, permanent decline
    • Fraud Failure β†’ stolen card, restricted card, suspicious activity
  4. Soft Failure Recovery Flow

    • Sends Slack alert to internal team
    • Checks if order is high-value
    • Sends retry email to customer
    • Waits before next retry
    • Counts retry attempts
    • Stops after retry limit
  5. Hard Failure Handling

    • Sends internal Slack notification
    • Logs failure for support / reporting
  6. Fraud Handling

    • Sends urgent Slack fraud alert
    • Prevents retry flow
    • Logs suspicious payment event
  7. Supabase Logging

    • Stores all failures with timestamp, customer email, retry count, order value, status and reason.

Who It’s For

This workflow is ideal for:

Requirements

How It Works

  1. Webhook Trigger

    • Workflow starts when a payment failure event is sent to the webhook endpoint.
  2. Normalize Data

    • Extracts payment details from webhook payload.
    • Converts provider-specific fields into a unified structure.
  3. Failure Detection Logic

    • Function node checks decline codes and error messages.
    • Categorizes failure into:
      • soft
      • hard
      • fraud
  4. Routing

    • Soft failures go to retry recovery flow.
    • Fraud and hard failures go to separate alerting branches.
  5. Retry Recovery

    • Slack notification sent.
    • High-value order check performed.
    • Customer receives retry payment email.
    • Wait timer delays repeated reminders.
    • Retry count increases.
    • Stops after 3 attempts.
  6. Fraud Handling

    • Immediate Slack fraud alert.
    • Logs case in database.
  7. Hard Failure Handling

    • Team notified.
    • Case logged in database.
  8. Database Logging

    • All outcomes saved into Supabase.

Setup Instructions

  1. Import Workflow β†’ Workflows β†’ Import from File in n8n.
  2. Webhook Setup β†’ copy URL from Receive Payment Failure node.
  3. Payment Gateway Setup β†’ configure Stripe / Shopify / PayPal webhook to send failed payment events.
  4. Slack Credentials β†’ connect Slack account and choose alert channel.
  5. Gmail Credentials β†’ connect Gmail account for customer notifications.
  6. Supabase Setup β†’ connect Supabase and create payment_failure table.
  7. Configure Thresholds
    • High-value order threshold = 500
    • Retry limit = 3
    • Wait delay = 2 minutes
  8. Test Workflow using sample failed payments.
  9. Enable Workflow once validated.

Logic Overview

StepNodeDescription
1Webhook TriggerStarts workflow on failed payment webhook
2Normalize DataCreates standard payment fields
3Classify FailureDetects soft, hard or fraud
4Route by TypeBranches logic by failure category
5Soft AlertSends internal Slack notification
6High Value CheckChecks order amount β‰₯ threshold
7Customer Retry EmailEmails payment retry link
8DelayPrevents excessive reminders
9Increase CounterTracks retry attempts
10Limit CheckStops after max retries
11Fraud AlertUrgent suspicious payment alert
12Hard Failure AlertStandard non-retryable alert
13Database LoggingStores all results in Supabase

Customization Options

Optional Enhancements

Use Case Examples

  1. Recover failed subscription renewals automatically.
  2. Detect stolen card attempts in real time.
  3. Notify customers when cards have insufficient funds.
  4. Reduce abandoned orders caused by temporary payment issues.
  5. Track failed payment trends across gateways.
  6. Alert finance teams for high-value payment failures.

Troubleshooting Guide

IssuePossible CauseSolution
Workflow not receiving eventsWebhook misconfiguredVerify webhook URL and provider settings
Customer email not sentGmail credentials expiredReconnect Gmail OAuth
Slack alerts missingWrong channel ID or tokenUpdate Slack credentials
Soft failures not classifiedMissing decline codesUpdate Identify Failure Type logic
Retry loop not stoppingRetry limit condition incorrectVerify IF node logic
Supabase insert failsWrong table/credentialsCheck database schema and credentials
Order value incorrectCurrency conversion issueReview amount /100 logic
Fraud cases not flaggedNew fraud codes missingAdd provider fraud decline codes

Need Help?

If you need help setting up, customizing or extending this workflow, WeblineIndia can assist with full n8n workflow development, payment automation, revenue recovery systems, fraud monitoring, Slack integrations and custom business process automation.

πŸ”— Nodes Used

Function, Slack, Webhook, Gmail, Supabase

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup