Stripe Failed Payment Recovery Agent for Subscription Workflows
Learn how to build a Stripe failed payment recovery agent to handle subscription payment failures using Major, HubSpot, Slack, and Gmail.

A Stripe failed payment recovery agent can improve failed subscription payment recovery by automating retries, customer notifications, and escalations. This guide walks through setting up an agent to handle invoice.payment_failed events, use business context from HubSpot or Salesforce, and involve human approval for high-value accounts.
This guide covers one Stripe process end to end. For the Stripe API guide, connection setup and the full list of Stripe use cases, see More Stripe use cases.
Why This Process Breaks Today
Automated failed payment handling breaks down for several reasons:
- Business teams often rely on generic retry rules, missing important context like account size or ongoing sales conversations.
- If product and finance teams only use standard Stripe retry settings, nuanced customer outreach (personal emails, tailored payment links) does not happen in time.
- It's hard to pull customer history or opportunity status from HubSpot or Salesforce mid-process, so escalations are ad hoc or delayed.
- Coordination between payment, sales, and account teams is fragmented. Manual interventions often happen too late or not at all.
The Systems and Data Involved
This workflow connects several tools, each contributing specific data and functions:
Stripe
- Events:
invoice.payment_failedevent signals a failed payment attempt on a subscription. - Objects:
Invoice,Customer, andChargeobjects contain payment and account information. Decline codes, found on the last charge’sfailure_codeandfailure_message, indicate why a payment failed. - API Endpoints:
GET /invoices/{id}: Retrieve the full invoice.GET /customers/{id}: Retrieve customer details.GET /charges/{id}: Get charge specifics and error codes.
HubSpot or Salesforce
- Customer records and current engagement status (e.g., open opportunities, past interactions, account owner emails).
Slack
- Used for real-time notifications and human approvals, especially for high-value or strategic accounts.
Gmail
- Used for sending personalized email notifications to customers or internal stakeholders.
What Is Code vs What Is Agent Judgment vs What Needs Human Approval
Code (deterministic logic):
- Listening for
invoice.payment_failedevents from Stripe. - Looking up the subscription, customer, and past charge details.
- Querying HubSpot or Salesforce to enrich customer information.
Agent Judgment:
- Interpreting decline codes to decide if a retry is appropriate or if the card is unrecoverable.
- Determining the urgency based on account context. For example, deciding between automated email or escalation based on account value, opportunity status, or past interactions.
- Drafting a tailored outreach message or escalation note using the customer’s interaction history and payment attempt data.
Human Approval:
- For high-value or strategic accounts, the agent drafts an action (for example, a suspension notice or escalation to account management) and sends a review to a Slack channel for sign-off. No irreversible actions (like account suspension or cancellation) happen without explicit approval.
A Worked Example: Tracing a Failed Payment
Let’s walk through a typical failure:
Stripe Invoice Event:
{ "id": "in_001A2b3c4D5e", "object": "invoice", "customer": "cus_A123bCDe456F", "subscription": "sub_123abc456def", "status": "open", "attempted": true, "paid": false, "next_payment_attempt": 1719955200, ...}
Stripe posts an invoice.payment_failed event:
- Code: Handling the webhook
- Major receives the event from the Stripe connector. Use the invoice ID to fetch details from
/invoices/{id}andcustomervia/customers/{id}.
- Agent: Understanding charge failure
- The agent reviews the last charge attached to the invoice, finds a decline code (e.g.,
insufficient_funds), and reads thefailure_messagefor detail.
- Agent: Pulling CRM information
- Lookup the customer by email or ID in HubSpot. Finds the account owner, opportunity stage, and account value.
- Finds that this customer is linked to an open $60,000 renewal deal with an account owner named Pat Franco.
- Agent: Decision
- Since the failure code is not permanent, and the amount is high, the agent drafts a retry request and proposes that the account owner reach out personally.
- Agent: Slack escalation
- Agent posts a summary and proposed action to the #account-ops Slack channel:
“Payment failed (insufficient_funds) for Acme Inc, $5,000/mo renewal. Pat Franco owns the account. Should we retry or escalate to payment ops?”
- Waits for an approval emoji or response.
- Code and Human approval:
- If approved, the agent records the decision in Logs, triggers the retry, and drafts a Gmail for Pat Franco to send to the customer. Otherwise, the agent holds further action for more input.
How to Build It on Major
To reproduce this process, use three Major components: apps, agents, and workflows.
The App: Stripe Data and CRM Context
- Deploy an app in Major for each source:
- Stripe connector: Receives
invoice.payment_failedevents. Fetches details about the invoice, customer, and charge via the API. - HubSpot or Salesforce connector: Looks up contacts, deals, and account owner info using HubSpot association APIs or Salesforce queries.
- Gmail connector: Prepares and can send emails.
- Slack connector: Posts to specific channels and listens for approval replies.
- The app handles deterministic data fetching and pushing.
Agent: Applying Context and Judgment
- The agent receives a bundle of information: why the payment failed, deal stage from the CRM, whether this is their first failure, customer communication history, and any open tickets.
- Based on clear rules and prompts, the agent decides:
- Should Stripe retry, or is the failure fatal?
- Does the account owner need to be notified, or is a customer email enough?
- Should escalation or approval be requested in Slack (e.g., for accounts valued over $10,000)?
- The agent drafts personalized communications and posts reviewable decisions.
Workflow: Orchestrating the Steps
- The workflow is triggered by a Stripe event.
- Data fetch steps pull Stripe and CRM data. The agent receives all context, applies judgment, and determines the right branch:
- For low-value, auto-retry cases, the agent moves forward with a standard email from Gmail.
- For high-value accounts, the agent sends its proposed action to Slack for human review before triggering a retry or outreach.
- All major actions and approvals are logged in Major for audit.
What to Measure
Tracking recovery and escalation performance is key:
- Payment recovery rate: What percentage of failed payments are successfully retried?
- Response time: How quickly does the agent propose actions and how quickly do humans approve or intervene in Slack?
- High-value account NPS or feedback: Are account owners or sales teams satisfied with how sensitive payment failures are handled?
- Manual interventions: How often are humans needed, and in what scenarios can agent guidance reduce this?
Guardrails: What the Agent Must Never Do
Set boundaries to ensure reliability, compliance, and a good customer experience:
- Never cancel an account or suspend service without human approval for any high-value or strategic account.
- Never retry a payment if the decline code is unrecoverable (such as
card_declinedwith a permanent failure code) or if the customer is flagged for sensitive handling. - Never send a communication (Gmail or otherwise) containing sensitive payment failure details to channels or people not explicitly allowed in the rules.
- Never post any Stripe or customer PII outside preconfigured channels or CRM records.
- Always log actions, Human overrides, and Slack approvals in Major for traceability.
Frequently asked questions
What decline codes mean a payment should not be retried?
Permanent codes like 'lostcard', 'stolencard', and generic 'donotretry' mean a retry will not succeed. Cardholder needs to update their card info. The agent should flag these for manual follow-up.
How does the agent know when to escalate to Slack for approval?
The agent bases this on account value, opportunity stage, and custom business logic. For example, any failed payment linked to a deal over $10,000 or flagged as strategic in the CRM is escalated to the appropriate Slack channel before action.
Does the agent ever initiate retries on its own?
For low-value or standard accounts and only when the decline reason is temporary (like 'insufficient_funds'), the agent can initiate one scheduled retry. All actions are logged and non-standard attempts require review.
How are hand-offs to sales or account owners coordinated?
When outreach or escalation is needed, the agent prepares a draft in Gmail and notifies the account owner by email or through CRM task assignment. For high-value accounts, the draft and actions are first reviewed in Slack.
Start building on Major
Connect Stripe, describe the process, and Major builds the app that holds its state, the agent that makes the judgment call and the workflow that runs it, with scoped access and an audit log from the first deploy.
Frequently asked questions
- How do Stripe AI agents work with Stripe data in Major?
- Stripe AI agents use Stripe’s API to read, analyze, and take action on billing data. They can automate common tasks, flag issues, or suggest interventions, while letting humans approve or decline actions before they go live.
- What security measures are in place when connecting Stripe to Major?
- Stripe authentication requires a secret API key associated with your account. Major maintains scoping, audit logs and role-based access so only authorized workflows and agents interact with Stripe.
- Can Major replace Stripe’s internal automation features?
- Major is designed to orchestrate Stripe, not replace its internal features. Use Stripe for direct billing automation, and Major when you need cross-system workflows or custom approvals that span multiple tools.
- What Stripe objects are most commonly used by Stripe AI agents in Major?
- The most common objects are `Customer`, `Subscription`, and `Invoice`, as these represent key billing and customer lifecycle activities.
- How do I trigger workflows in Major based on Stripe events?
- Use Stripe’s webhook events, like `customer.subscription.updated` or `invoice.payment_succeeded`, to kick off workflows in Major. Major checks the event signature and acts based on your business logic.