Stripe Failed Payment Dunning
When a Stripe invoice payment fails, the flow starts a dunning sequence — escalating customer emails, retries on a schedule, a grace-period timer, and an alert to finance — and updates the customer's status in Dataverse when resolved or churned. Recovers failed payments and reduces involuntary churn.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
This flow runs an automated, escalating dunning sequence to recover failed Stripe invoice payments and reduce involuntary churn. On a daily schedule it lists open invoices that failed automatic collection, enriches each with live customer detail from the Stripe connector, advances a per-invoice Dataverse ledger through escalating email reminders, churns cases that exhaust the reminder stages or breach a grace period, reconciles recoveries (invoices that no longer appear as failed), and emails finance a run summary.
Why it matters: Failed cards silently bleed revenue. A structured, stateful dunning sequence recovers payments that would otherwise be lost — and gives finance a governed audit trail of every contact, churn, and recovery.
Status: Built (API-first). Ships Off (demo). Flow Checker: 0 errors / 0 warnings.
Use Case
A subscription business wants automated, escalating recovery for failed Stripe payments, with a Dataverse system-of-record for each customer's dunning state and a daily finance summary.
Flow Architecture
Run Daily Dunning Scan
Recurrence (Day/1, 08:00)Daily scan of failed Stripe invoices.
Initialize correlation id + config
Initialize VariableMint a correlation id and load env vars/thresholds: Stripe key/base, finance alert email, grace period days, max dunning stage, and counters.
Get Failed Stripe Invoices
HTTP — GET /v1/invoicesGET open invoices with collection_method=charge_automatically (Bearer key) — no connector list op exists.
Parse Stripe Invoices
Parse JSONParse the invoices payload (id, customer, amount_due, currency, hosted_invoice_url).
For Each Failed Invoice
Foreach (sequential)Process each failed invoice.
Get Stripe Customer
Stripe — GetCustomerEnrich with live customer email / delinquency.
List Existing Dunning Record
Microsoft Dataverse — ListRecordsLook up the invoice in the dunning ledger.
New invoice branch
Microsoft Dataverse — CreateRecord + Office 365 Outlook — SendEmailV2Create a stage-1 ledger record and send the first dunning email.
Churn branch
Microsoft Dataverse — UpdateRecord + Office 365 Outlook — SendEmailV2When stage > max OR grace period elapsed: mark Churned, count, and alert finance.
Escalate branch
Microsoft Dataverse — UpdateRecord + Office 365 Outlook — SendEmailV2Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_StripeApiKey | String | sk_live_REPLACE_ME | Stripe secret API key for the REST Authorization Bearer header. |
| flowlibs_StripeApiBaseUrl | String | https://api.stripe.com/v1 | Stripe REST base URL. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Stripe | shared_stripe | GetCustomer |
| HTTP | http | GET /v1/invoices |
| Microsoft Dataverse | shared_commondataserviceforapps | ListRecords CreateRecord UpdateRecord |
| Office 365 Outlook | shared_office365 | SendEmailV2 |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Retry cadence / stages
- Change varMaxDunningStage (number of reminders) and varGracePeriodDays (hard churn cutoff).
- Schedule
- Adjust the Recurrence trigger (frequency/time) for more or less frequent scanning.
- Email content
- Edit the subject/body strings in the four SendEmailV2 actions; the Stripe hosted_invoice_url is already linked.
- Finance routing
- Change varFinanceAlertEmail to reroute churn alerts and the daily summary.
- Segment dunning
- Branch on the Get Stripe Customer output (e.g. a gentler cadence for VIPs).
- Go-live
- Authorize the three connections and set the flowlibs_StripeApiKey value, then turn the flow On.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01Failed-invoice query (HTTP URI)
Stripe REST query for open, auto-collected invoices.
EXPR.02Next dunning stage
Advance the dunning stage for an existing invoice.
EXPR.03Churn decision (stage OR grace period)
Churn when the stage exceeds the max or the grace period has elapsed.
EXPR.04Recovery detection
An active invoice no longer in the failed set has recovered.
EXPR.05Amount display (cents to currency)
Format the amount due as currency.
Customize & download
Generate a ready-to-import copy of this solution with your environment-variable values baked in — available on Base, Pro, or Team.
Upgrade to customize
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.