Send failed Stripe invoices to a HubSpot billing owner
A failed invoice needs a human review before it becomes another unnoticed item in the billing dashboard.
Integrations used in this example
Give failed invoices a place in the team's work queue
Stripe can retry a payment and send billing emails. This example adds an internal handoff: when an invoice payment fails, it retrieves the invoice and creates a high-priority HubSpot task for a billing owner you choose. The task includes the customer email Stripe supplied, a hosted invoice link when available, and the event ID.
The owner still needs to check the invoice's current state and find the right customer record before contacting anyone. The example assigns every failed invoice to one billing owner rather than guessing which HubSpot contact or account manager it belongs to. It records a human next step without changing the subscription or sending another billing email.
A B2B SaaS operator expanding into the US reported a much higher failed-invoice rate than in its home markets and asked how to recover those payments.Source: A SaaS operator's failed-invoice question on Reddit
What you'll tell the agent
- The Stripe account whose failed invoices should create tasks.
- The HubSpot billing owner who should review every task.
- Account authorization.
The agent will create the project and ask you for these details. When Automate.ax asks you to connect an account, authorize the integrations you want this workflow to use.
Start with the setup prompt. The agent will create the Automate.ax project, guide you through connecting Stripe and HubSpot, and ask for values it cannot discover from your accounts.
The automation
The Stripe event identifies the failed invoice. The automation fetches its email and hosted invoice link, then creates a HubSpot task for the configured billing owner.
import { automation, t } from "automate.ax"
import { hubspot } from "automate.ax/hubspot"
import { stripe } from "automate.ax/stripe"
export default automation(
"Give failed invoice payments an owner in HubSpot",
{
parameters: [
{
label: "HubSpot billing owner ID",
name: "billingOwnerId",
type: "text",
},
],
},
({ parameters }) => {
const failure = stripe.onInvoicePaymentFailed()
const invoice = stripe.getInvoice({ invoiceId: failure.data.object.id })
const details = invoice.transform(
({ customerEmail, hostedInvoiceUrl }) => ({
customerEmail: customerEmail ?? "Not supplied by Stripe",
invoiceUrl: hostedInvoiceUrl ?? "Open the invoice in Stripe",
}),
)
hubspot.createTask({
timestamp: failure.created.transform(
(seconds) => new Date(seconds * 1000),
),
ownerId: parameters.billingOwnerId,
subject: t`Review failed payment for Stripe invoice ${invoice.id}`,
body: t`Customer: ${details.customerEmail}\nInvoice: ${details.invoiceUrl}\nStripe event: ${failure.id}\nReview the payment and contact the customer if needed.`,
priority: "HIGH",
taskType: "TODO",
})
},
)
What a run looks like
Example input
An invoice payment fails for a Stripe customer whose email is maya@example.com.
Expected result
The configured HubSpot billing owner gets a high-priority task naming the invoice, maya@example.com, the hosted invoice link if Stripe provides it, and the Stripe event ID.
Set it up
- Copy the setup prompt at the top into your coding agent.
- Choose the HubSpot billing owner who should receive failed-invoice tasks. The agent can help you find that owner's ID after you connect HubSpot.
- Authorize Stripe and HubSpot when prompted. Review the task body, especially what happens when Stripe has no customer email or hosted invoice link.
- Deploy the automation, then trigger a Stripe test invoice failure and inspect the HubSpot task.
Check the result
Trigger an invoice payment failure in Stripe test mode. Confirm the task goes to the selected HubSpot owner and contains the correct invoice ID, customer email, link when available, and Stripe event ID. Check the live invoice state before treating the task as unresolved.
Where this workflow stops
- Stripe may retry an invoice and email the customer on its own. This workflow is for internal follow-up and should not send a second automatic payment demand.
- A failed attempt is not a lost subscription. The account owner should check the invoice's current status before contacting the customer.
- The task is not associated with a HubSpot contact. The billing owner must verify the customer before reaching out.
- Repeated failure events can create more than one task for an invoice. Add a deduplication rule before using this with a high-volume billing queue.
Common questions
Will this retry the payment?
No. Stripe remains responsible for payment retries. The automation gives your team the context for a personal follow-up.
Does this find the customer's HubSpot contact?
No. The task goes to the billing owner you choose. That person can verify the customer record using the Stripe invoice details.
Can I limit this to high-value accounts?
The example handles every invoice payment failure. Ask the agent to add an amount or plan rule if your team only wants a subset.