Stripe Invoice Payment Failed Notification to Slack & Email
Use the Stripe integration by MagicBell to setup a workflow when invoice.payment.failed triggers in Stripe.
Connect Stripe to MagicBell to receive events and trigger workflows. This guide uses the MagicBell CLI.
Add the Stripe integration
Save your Stripe webhook signing secret in MagicBell. See Stripe webhooks.
magicbell integration save_stripe \
--data '{"webhook_signing_secret":"whsec_xxx"}'Copy the ID from the response and use it to build your webhook URL:
https://api.magicbell.com/v2/integrations/stripe/webhooks/incoming/{id}Setup the webhook
- Setup a webhook in Stripe with the URL from the last step.
- Select the invoice.payment.failed event.
- If you already have a webhook configured, make sure it includes this event.
Add a workflow
Create a workflow that triggers automatically when Stripe sends this event.
Workflow key
Use this key to trigger the workflow when Stripe sends a invoice.payment.failed:
integration.stripe.invoice.payment_failedExample workflow
Notify customers immediately when payment fails with a link to update their payment method. Escalate to the billing team after 48 hours if still unpaid.
{
"key": "integration.stripe.invoice.payment_failed",
"steps": [
{
"command": "broadcast",
"input": {
"action_url": "{{payload.data.object.hosted_invoice_url}}",
"content": "We couldn't process your payment of ${{payload.data.object.amount_due}}. Please update your payment method to avoid service interruption.",
"recipients": [
{
"external_id": "{{payload.data.object.customer}}"
}
],
"title": "Payment failed"
}
},
{
"command": "wait",
"input": {
"duration": 172800
}
},
{
"command": "broadcast",
"input": {
"content": "Invoice {{payload.data.object.number}} for customer {{payload.data.object.customer}} has been unpaid for 48 hours. Amount: ${{payload.data.object.amount_due}}. Manual intervention may be needed.",
"overrides": {
"providers": {
"email": {},
"slack": {}
}
},
"recipients": [
{
"external_id": "billing-team"
}
],
"title": "Payment still failing"
}
}
]
}Save with the CLI
Use the MagicBell CLI to save this workflow to your project. You can also use the Workflows API endpoint instead.
magicbell workflow save \
--data '{"key":"integration.stripe.invoice.payment_failed","steps":[{"command":"broadcast","input":{"action_url":"{{payload.data.object.hosted_invoice_url}}","content":"We couldn't process your payment of ${{payload.data.object.amount_due}}. Please update your payment method to avoid service interruption.","recipients":[{"external_id":"{{payload.data.object.customer}}"}],"title":"Payment failed"}},{"command":"wait","input":{"duration":172800}},{"command":"broadcast","input":{"content":"Invoice {{payload.data.object.number}} for customer {{payload.data.object.customer}} has been unpaid for 48 hours. Amount: ${{payload.data.object.amount_due}}. Manual intervention may be needed.","overrides":{"providers":{"email":{},"slack":{}}},"recipients":[{"external_id":"billing-team"}],"title":"Payment still failing"}}]}'Event payload
Sample payload for the invoice.payment.failed event. Use liquid templates to access fields in your workflow.
{
"account": "",
"api_version": "2025-08-27.basil",
"context": "",
"created": 1764065326,
"data": {
"object": {
"account_country": "US",
"account_name": "Development",
"account_tax_ids": null,
"amount_due": 2000,
"amount_overpaid": 0,
"amount_paid": 0,
"amount_remaining": 2000,
"amount_shipping": 0,
"application": null,
"attempt_count": 1,
"attempted": true,
"auto_advance": false,
"automatic_tax": {
"disabled_reason": null,
"enabled": false,
"liability": null,
"provider": null,
"status": null
},
"automatically_finalizes_at": null,
"billing_reason": "manual",
"collection_method": "charge_automatically",
"created": 1764065323,
"currency": "usd",
"custom_fields": null,
"customer": "cus_TUHkz63gW41i4G",
"customer_address": null,
"customer_email": null,
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
"customer_tax_exempt": "none",
"customer_tax_ids": [],
"default_payment_method": null,
"default_source": null,
"default_tax_rates": [],
"description": "(created by Stripe CLI)",
"discounts": [],
"due_date": null,
"effective_at": 1764065324,
"ending_balance": 0,
"footer": null,
"from_invoice": null,
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_1S546LIvz5j75Cdb/test_YWNjdF8xUzU0NkxJdno1ajc1Q2RiLF9UVUhraEo2Q2NvYjR0T0MyN2dLSDdnclYyU2R5emZnLDE1NDYwNjEyNw020083Dhpggr?s=ap",
"id": "in_1SXJAtIvz5j75CdbK1yFGg0d",
"invoice_pdf": "https://pay.stripe.com/invoice/acct_1S546LIvz5j75Cdb/test_YWNjdF8xUzU0NkxJdno1ajc1Q2RiLF9UVUhraEo2Q2NvYjR0T0MyN2dLSDdnclYyU2R5emZnLDE1NDYwNjEyNw020083Dhpggr/pdf?s=ap",
"issuer": {
"type": "self"
},
"last_finalization_error": null,
"latest_revision": null,
"lines": {
"data": [
{
"amount": 2000,
"currency": "usd",
"description": "(created by Stripe CLI)",
"discount_amounts": [],
"discountable": true,
"discounts": [],
"id": "il_1SXJAtIvz5j75CdbtjCao5Tn",
"invoice": "in_1SXJAtIvz5j75CdbK1yFGg0d",
"livemode": false,
"metadata": {},
"object": "line_item",
"parent": {
"invoice_item_details": {
"invoice_item": "ii_1SXJAtIvz5j75CdboBNKyYmO",
"proration": false,
"proration_details": {
"credited_items": null
},
"subscription": null
},
"subscription_item_details": null,
"type": "invoice_item_details"
},
"period": {
"end": 1764065323,
"start": 1764065323
},
"pretax_credit_amounts": [],
"pricing": {
"price_details": {
"price": "price_1SXJAtIvz5j75CdbOjiBk64D",
"product": "prod_TUHklyFfc63GkN"
},
"type": "price_details",
"unit_amount_decimal": "2000"
},
"quantity": 1,
"taxes": []
}
],
"has_more": false,
"object": "list",
"total_count": 1,
"url": "/v1/invoices/in_1SXJAtIvz5j75CdbK1yFGg0d/lines"
},
"livemode": false,
"metadata": {},
"next_payment_attempt": null,
"number": "829BPNMD-0001",
"object": "invoice",
"on_behalf_of": null,
"parent": null,
"payment_settings": {
"default_mandate": null,
"payment_method_options": null,
"payment_method_types": null
},
"period_end": 1764065323,
"period_start": 1764065323,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
"receipt_number": null,
"rendering": {
"amount_tax_display": null,
"pdf": {
"page_size": "letter"
},
"template": null,
"template_version": null
},
"shipping_cost": null,
"shipping_details": null,
"starting_balance": 0,
"statement_descriptor": null,
"status": "open",
"status_transitions": {
"finalized_at": 1764065324,
"marked_uncollectible_at": null,
"paid_at": null,
"voided_at": null
},
"subtotal": 2000,
"subtotal_excluding_tax": 2000,
"test_clock": null,
"total": 2000,
"total_discount_amounts": [],
"total_excluding_tax": 2000,
"total_pretax_credit_amounts": [],
"total_taxes": [],
"webhooks_delivered_at": null
},
"previous_attributes": null
},
"id": "evt_1SXJAxIvz5j75Cdbc84ixIMX",
"livemode": false,
"object": "event",
"pending_webhooks": 3,
"request": {
"id": "req_wkIDI1VsG2iLk0",
"idempotency_key": "eeac7a69-8eb8-4c6d-b254-553d7efff8b7"
},
"type": "invoice.payment_failed"
}